Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I have an android application that I'm working on with a custom theme applied to it in the android manifest on the main activity itself. This activity creates a listview, which has the style applied to it.

If I create a custom layout for that listview, including a separate xml file for the rows themselves, and I apply styling directly to those layouts, does this style overwrite the overall style for the application? I'm trying to get a grasp on the hierarchy of events as far as how styling and themeing works.

The way I'm GUESSING it works in my example is: apply style for row, referenced by row layout xml > apply style for overall listview, referenced by listview layout xml > apply style from custom theme, referenced by style xml referenced by android manifest

Am I right? Or am I approaching this incorrectly. (just for confusions sake, by ">" I mean has a greater importance than)

like image 236
optionsix Avatar asked Jul 13 '11 20:07

optionsix


1 Answers

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
like image 152
Khaled Qasem Avatar answered Oct 05 '22 13:10

Khaled Qasem