Android - Preference of view attributes defined in layout, styles, activity and application theme

   Android's view attributes could be defined in different places like layout, styles and theme. This however leads to a possibility where in an attribute could be defined in multiple places and in such cases, android gives more preference to local specification in the following sequence (based on Android Kitkat 4.4)

  * The value specified explicitly in the layout get first preference

                android:textColor="#ff10ff30"

  * The value specified by a style gets the next preference

                style="@style/TextStyle.Red"

  * The value specified by a style in the corresponding activity's theme gets the next preference. The value is picked from the activity's theme definition of textStyle.

                style="?attr/textStyle"

  * The value specified by a style in the corresponding application's theme gets the final preference. The value is picked from the application's theme definition of textStyle.

                style="?attr/textStyle"

No comments: