Style hierarchy in Android - what is the order of importance? Style hierarchy in Android - what is the order of importance? xml xml

Style hierarchy in Android - what is the order of importance?


If you've specified the same attributes in multiple places, the list below determines which attributes are ultimately applied. The list is ordered from highest precedence to lowest:

  1. Applying character- or paragraph-level styling via text spans to TextView-derived classes
  2. Applying attributes programmatically
  3. Applying individual attributes directly to a View
  4. Applying a style to a View
  5. Default styling
  6. Applying a theme to a collection of Views, an activity, or your entire app
  7. Applying certain View-specific styling, such as setting a TextAppearance on a TextView


Hope I am understand your question right here...

The styles you define in styles.xml will always overwrite the styles coming from the theme currently used by android.

But this only works for the attributes you overwrite.

If you leave an attribute untouched, android will provide the style for it, and sometimes this comes bite you in the butt :)

This system is best described like this:A textview requires an attribute example

<item name="android:textColor">#00FF00</item>

Android will first look in the original layout.If not found, it will look into your custom styles.If not found, it will look into android styles.

Hope this helps.


The standard themes have lines like which define the ListView style:

    <item name="listViewStyle">@android:style/Widget.ListView</item>

In your own theme you can do a

    <item name="listViewStyle">@style/MyOwnListView</item>

Something that is not defined in the ListView style (own or default) will be what is defined in the theme if you have defined it there.