Ứng dụng của tôi có tab có hai chủ đề. Trong mỗi tab chủ đề có hình ảnh khác nhau ở trạng thái đã chọn và không được chọn. Làm thế nào tôi có thể tham khảo đúng cách hình ảnh theo chủ đề?Cách tham chiếu từ drawable to style
Ví dụ: Tôi có trong themes.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>
Ngoài ra tôi có một tab_shows.xml và 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" />
Làm thế nào tôi có thể tham khảo hình ảnh cần thiết trong bộ chọn theo chủ đề hiện tại? này không làm việc cho tôi
<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" />
Trong file bố trí làm việc này, tôi có nghĩa là tài liệu tham khảo phong cách qua? StyleName
Got cùng một vấn đề ở đây: http://stackoverflow.com/q/12115125/317889 – HGPB
Tôi đang làm một cái gì đó tương tự ĐÂY !!! http://stackoverflow.com/questions/17103894/overriding-referenced-style-attributes – toobsco42