I am trying to figure out how to organize an Android application that will have several themes. here is a simplified example of my problem,
2 themes, "light" and "dark",
each topic has two text colors: "on" and "off"
Now the problem is that when I define my TextView, I don’t want to call “light” or “dark” there, I just want to specify the theme at the application level and apply it. basically, I want CSS selectors. I want to define my topic as,
<style name="Light.enabled" .../> <style name="Light.disabled" .../>
and my textual representation for example
<TextView style="@style/.enabled" .../> <TextView style="@style/.disabled" .../>
and whether it’s applied “on” or “off” depending on whether I caused “light” or “dark” at the application level.
this page, http://www.androidengineer.com/2010/06/using-themes-in-android-applications.html
shows the application that
defines a style, for example "light.enabled"
# 000000
defines an attribute reference, for example, "enabled"
defines a style (theme), for example,
@ Style / light.enabled
uses attr to determine the style in the view,
this is what i want, but it does not work for me. the only diff is that I'm using appwidget. The author sets the topic of activity. the only place I can set is Context.setTheme () and in the "application" tag in the manifest. none of which seem to matter.
source share