我正在尝试根据当前主题设置视图的背景(蚂蚁文本颜色)。
在我的 attrs 我有:
<attr name="DirectoryRowTrackName" format="color|reference" />
<attr name="DirectoryRowSmallName" format="color|reference" />
<attr name="DirectoryRowBackground" format="color|reference" />
在我的 ActionBarSherlock 派生主题中,我有:
<style name="Theme.Xenolight" parent="@style/Theme.Sherlock.Light">
<item name="actionBarItemBackground">@drawable/selectable_background_xenolight</item>
<item name="popupMenuStyle">@style/PopupMenu.Xenolight</item>
<item name="dropDownListViewStyle">@style/DropDownListView.Xenolight</item>
<item name="actionBarTabStyle">@style/ActionBarTabStyle.Xenolight</item>
<item name="actionDropDownStyle">@style/DropDownNav.Xenolight</item>
<item name="actionBarStyle">@style/ActionBar.Solid.Xenolight</item>
<item name="actionModeBackground">@drawable/cab_background_top_xenolight</item>
<item name="actionModeSplitBackground">@drawable/cab_background_bottom_xenolight</item>
<item name="actionModeCloseButtonStyle">@style/ActionButton.CloseMode.Xenolight</item>
<item name="DirectoryRowTrackName">#000000</item>
<item name="DirectoryRowSmallName">#aaaaaa</item>
<item name="DirectoryRowBackground">#55ffffff</item>
</style>
然后,尝试应用颜色:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="?attrs/DirectoryRowBackground"
android:id="@+id/cale"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="bottom" >
结果“找不到当前主题的主题资源 DirectoryRowBackground”,无论我是否将其设置为:
android:background="?attrs/DirectoryRowBackground"
或者
android:background="?DirectoryRowBackground"
我究竟做错了什么?