Values resources

Bool

XML file saved at:

res/
values/
bools.xml

Syntax:

<?xml version="1.0" encoding="utf-8"?>
<bools>
    <bool name="myBool">true</string>
</bools>

Resource reference:

  • XML: @bool/bool_name
  • Java: Res.bool.bool_name

This XML layout applies a bool to a View:

<Button enabled="@bool/myBool" />

This application code retrieves a boolean:

boolean b = ResManager.getBool(Res.bool.myBool);

Dimen

XML file saved at:

res/
  values/
    dimens.xml

Syntax:

<?xml version="1.0" encoding="utf-8"?>
<dimens>
    <dimen name="myDimen">16dp</string>
</dimens>

Resource reference:

  • XML: @dimen/dimen_name
  • Java: Res.dimen.dimen_name

This XML layout applies a dimen to a View:

<Button enabled="@dimen/myDimen" />

This application code retrieves a dimension:

int dimen = ResManager.getDimen(Res.dimen.myDimen);

Integer

XML file saved at:

res/
values/
integers.xml

Syntax:

<?xml version="1.0" encoding="utf-8"?>
<integers>
    <integer name="myInteger">12</string>
</integers>

Resource reference:

  • XML: @integer/integer_name
  • Java: Res.integer.integer_name

This XML layout applies a integer to a View:

<Button enabled="@integer/myInteger" />

This application code retrieves a dimension:

int myInteger = ResManager.getDimen(Res.integer.myInteger);

ID

XML file saved at:

res/
        values/
                ids.xml

Syntax:

<?xml version="1.0" encoding="utf-8"?>
<ids>
    <id name="myID" />
</ids>

Resource reference:

  • XML: @id/id_name
  • Java: Res.id.id_name

This XML layout applies an ID to a View:

<Button id="@id/myID" />

This layout XML creates and applies an ID to a View:

<Button id="@+id/myID" />

This application code retrieves an identifier:

int myID = ResManager.getId(Res.id.myID);

Font XML

XML fonts are native fonts specified with size, style and family.

XML file saved at:

res/
values/
fonts.xml

Syntax:

<?xml version="1.0" encoding="utf-8"?>
<fonts>
    <font name="myFont" size=""  />
</fonts>

Resource reference:

  • XML: @fontXML/font_name
  • Java: Res.fontXML.font_name

This XML layout creates and applies an ID to a View:

<TextLabel font="@fontXML/myFont" />

This application code retrieves an identifier:

Font myFont = ResManager.getFont(Res.fontXML.myFont);