My app with tabs has two themes. In each theme tabs have different images in selected and unselected state. How I can properly reference to image by theme?
For examp
Build your style A
and style B
in your case you put android:drawable="@drawable/ic_tab_shows_selected_light"
instead of background (I just copied snipets from my code)
#000
<style name="styleB">
<item name="android:background">#000</item>
</style>
your theme A
<style name="Theme.A">
<item name="pageBackground">@style/styleA</item>
</style>
theme B
<style name="Theme.Blue">
<item name="pageBackground">@style/styleB</item>
</style>
in your attr.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<attr name="pageBackground" format="reference" />
</resources>
finally in your widget you do style="?pageBackground"
You can find your answer here http://www.androidengineer.com/2010/06/using-themes-in-android-applications.html
Edit
(Additional information by Lukap in comments)
themes.xml
and set the definitions of your styles there. attrs.xml
. styles.xml
. But you will need read more about the attrs.xml
<item name="android:background">? android:attr/activatedBackgroundIndicator</item>
</style>
Instead, we are referring to the value of some other attribute – activatedBackgroundIndicator
– from our inherited theme. Whatever the theme defines as being the activatedBackgroundIndicator
is what our background should be.