I'm a beginner in Android development and, although coding makes perfect sence, android themes IMHO don't
I have trouble implementing this simple task:
I have (for example) a color named "blah"
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="blah">#F0F0F0</color>
<resources>
which is used everywhere in XML layouts or code and by different view complonents as "@color/blah"
I would simply like to make this color value change per-theme
So when i use MyTheme1, blah should be #F0F0F0 and when i use MyTheme2 blah should be #00FF00
I've been reading about themes and still cant find out how to implement this simple task, since my app does not require special styles and so on, just per-theme colors.
Thanx in advance
UPDATE:
After the link provided by Mohamed_AbdAllah, i successfully managed to create some custom colors by defining them in attrs.xml and styles.xml:
attrs.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<attr name="color_item_title" format="color|reference" />
</resources>
styles.xml
<style name="AppBaseThemeDark" parent="android:Theme.Black">
<item name="color_item_title">@color/White</item>
</style>
But now a much more serious problem arises
I can successfully use the color ?color_item_title in every view, so buttons and text actually gets that color.
But using that ?color_item_title on custom drawables or listview layouts (THAT IS VIEWS THAT GET INFLATED DURING RUNTIME) causes a crash.
So using ?color_item_title inside a listview listitem layout crashes at runtime with an inflater message at that line :(
It also crashes at my drawables: (Inflation error again)
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="@color/Black" />
<corners
android:bottomLeftRadius="8dp"
android:bottomRightRadius="8dp"
android:topLeftRadius="8dp"
android:topRightRadius="8dp" />
<stroke android:width="1dp" android:color="?color_item_title" />
</shape>