More resource types

This page defines the following types of resources that you can externalize:

Bool
XML resource that carries a boolean value.
Color
XML resource that carries a color value (a hexadecimal color).
Dimension
XML resource that carries a dimension value (with a unit of measure).
ID
XML resource that provides a unique identifier for application resources and components.
Integer
XML resource that carries an integer value.
Integer array
XML resource that provides an array of integers.
Typed array
XML resource that provides a TypedArray (which you can use for an array of drawables).

Bool

A boolean value defined in XML.

Note: A bool is a simple resource that is referenced using the value provided in the name attribute, not the name of the XML file. As such, you can combine bool resources with other simple resources in one XML file, under one <resources> element.

file location:
res/values/filename.xml
The filename is arbitrary. The <bool> element's name is used as the resource ID.
resource reference:
In Java: R.bool.bool_name
In XML: @[package:]bool/bool_name
syntax:
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <bool
        name="bool_name"
        >[true | false]</bool>
</resources>
elements:
<resources>
Required. This is the root node.

No attributes.

<bool>
A boolean value: true or false.

Attributes:

name
String. A name for the bool value. This is used as the resource ID.
example:
XML file saved at res/values-small/bools.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <bool name="screen_small">true</bool>
    <bool name="adjust_view_bounds">true</bool>
</resources>

The following application code retrieves the boolean:

Kotlin

val screenIsSmall: Boolean = resources.getBoolean(R.