【问题标题】:customizing Actionbar compact item selector自定义 Actionbar 紧凑项目选择器
【发布时间】:2014-05-15 17:54:44
【问题描述】:

我知道这个标题有很多问题,但我的问题还没有解决。

我使用 ActionBar Compact 来实现 actionbar。

现在,我想更改它的选择器(项目突出显示)颜色。

我用这个代码做选择器:

<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中

但是没有用。

我也用过这个链接:

selectable item background

how can i change the touch affect color of actions with actionbarsherlock

actionbarcompat support library android selectable item background not working

但还是不行。

【问题讨论】:

    标签: android android-actionbar android-theme android-actionbar-compat


    【解决方案1】:

    您可以使用http://jgilfelt.github.io/android-actionbarstylegenerator/ 的 ActionBar 主题生成器来制作您想要的内容。超级简单,结果很好;只需将文件提取到您的项目中并在清单中设置主题(或者以编程方式,如果那是您的事情)。我将它与http://android-holo-colors.com/ 结合使用,以使我的整个应用程序遵循一个共同的主题,但您需要在 XML 中移动一些内容以使这两个主题显示为一个。

    【讨论】:

      猜你喜欢
      • 2017-07-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-10-13
      相关资源
      最近更新 更多