Support for multiple themes in an Android app

Has anyone implemented support for multiple themes for an Android app? Are there any general practices for this?

Thanks for any advice.

UPD: The main problem at the moment is that the Android theme engine does not support selectors, for example, in CSS. For example, if I have two views with the "background" attribute, then there is no way to make the theme engine different from them and set different backgrounds. I can specify a different style for each type, but this approach does not have flexibility, because it is impossible to immediately apply the style to all activities.

+1
android themes
Aug 13 '10 at 8:38
source share
2 answers

As far as I know, there is no way to set a theme for the entire application in a line of code. If you want to change the topic of activity, you need to call setTheme() in your onCreate() method, BEFORE calling setContentView . To make your work easier, you can include all of your topics and select one of them in relation to what the user has selected. Now, if you want it to be easily applicable to all your actions, you can make all your actions a subclass of the custom Activity in which you would only set the theme. Activity <- ThemeActivity <- all your actions

+3
Aug 13 '10 at 11:10
source share

You should use android attrs.xml to define attributes of dynamic style. I wrote a blog about how to do this:

http://blabadi.blogspot.com/2015/01/android-multiple-themes-for-one.html

hope this helps.

+1
Jan 10 '15 at 12:45
source share



All Articles