Style resource

XML file saved at:

res/
  style/
    myStyle.xml

Syntax:

<?xml version="1.0" encoding="utf-8"?>
<style
    text="@string/myText"
    id="@id/myID"
    padding="@dimen/myPadding"
    backgroundColor="@color/myBackground" />

Resource reference:

  • XML: @style/style_name
  • Java: Res.style.style_name

This layout XML applies a style to a View:

<TextLabel style="@style/myStyle" />

The label will inherits from style properties.

This application code retrieves an identifier:

Style myStyle = ResManager.getStyle(Res.style.myStyle);