There are two topics in my tabbed application. The tabs for each topic have different images in the selected and unselected state. How can I refer to a related image correctly?
For example. I have in theme.xml
<?xml version="1.0" encoding="utf-8"?> <style name="LightTheme" parent="@android:style/Theme.Light"> <item name="tabShows">@drawable/ic_tab_shows_unselected_light</item> <item name="tabShowsSelected">@drawable/ic_tab_shows_selected_light</item> <item name="tabNews">@drawable/ic_tab_news_selected_light</item> <item name="tabNewsSelected">@drawable/ic_tab_news_unselected_light</item> </style> <style name="DarkTheme" parent="@android:style/Theme.Black"> <item name="tabShows">@drawable/ic_tab_shows_unselected_dark</item> <item name="tabShowsSelected">@drawable/ic_tab_shows_selected_dark</item> <item name="tabNews">@drawable/ic_tab_news_selected_dark</item> <item name="tabNewsSelected">@drawable/ic_tab_news_unselected_dark</item> </style>
I also have tab_shows.xml and tab_news.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_selected="true" android:drawable="@drawable/ic_tab_shows_selected_light"/> <item android:state_selected="false" android:drawable="@drawable/ic_tab_shows_unselected_light" />
How can I refer to the required image in the selector according to the current theme? This does not work for me
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_selected="true" android:drawable="?tabShowsSelected"/> <item android:state_selected="false" android:drawable="?tabShows" />
In the layout files, this works, I mean the style link through? styleName
android reference image styles themes
Georgy Gobozov Sep 23 '11 at 13:19 2011-09-23 13:19
source share