We will set its content view to preferences.xml using addPreferencesFromResource ThemePreferenceActivity is our PreferenceActivity. Our theme values will be defined in themes string-array. The theme values are specified in string-array. We will define a ListPreference which will display a list of theme names. In order to know which theme to apply, we will use android’s perferences. Once a theme is applied, the actual value will replace the placeholder. In our main screen, we will refer to our custom attributes using ?attr, for example ?attr/textColor. We have created two themes Theme1 and Theme2.Įach theme consists of textColoe, background and textSize. Now we will group our custom attributes together, give a name to the style and assign some values to them. For example, below we define few color resources. Before that you can define some style attributes and assign a value. This is just like declaring your program variables. We will define few custom attributes using attr element. android change theme programmatically Define Attributes Let’s try the above steps on our example.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |