我知道这个标题有很多问题,但我的问题还没有解决。
我使用ActionBar Compact来实现操作栏。
现在,我想更改其选择器(项目突出显示)颜色。
我将此代码用于选择器:
<item android:state_window_focused="false" android:drawable="@color/MyColor_Transparent" />
<!-- Even though these two point to the same resource, have two states so the drawable will invalidate itself when coming out of pressed state. -->
<item android:state_focused="true" android:state_enabled="false" android:state_pressed="true" android:drawable="@drawable/myforebackground_green" />
<item android:state_focused="true" android:state_enabled="false" android:drawable="@drawable/myforebackground_green" />
<item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/mybackground_b" />
<item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/mybackground_b" />
<item android:state_focused="true" android:drawable="@drawable/mybackground_b" />
<item android:drawable="@color/MyColor_Transparent" />
并且还使用了:
<item name="android:selectableItemBackground">@drawable/my_selector</item>
在styles.xml中
但它没有用。
我也使用过这个链接:
how can i change the touch affect color of actions with actionbarsherlock
actionbarcompat support library android selectable item background not working
但它仍无效。
答案 0 :(得分:1)
您可以使用http://jgilfelt.github.io/android-actionbarstylegenerator/上的ActionBar主题生成器来制作您想要的内容。超级简单,结果很棒;只需将文件提取到项目中并在清单中设置主题(或者以编程方式设置主题,如果这是你的事情)。我将它与http://android-holo-colors.com/结合起来使我的整个应用程序遵循一个共同的主题,但是您需要在XML中移动一些东西以将两个主题显示为一个。