我怎样才能改变“小三角彩”在行动吧NAVIGATION_MODE_LIST [英] How can I change the 'little triangle color' in action bar NAVIGATION_MODE_LIST

查看:265
本文介绍了我怎样才能改变“小三角彩”在行动吧NAVIGATION_MODE_LIST的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设置后行动起来吧 NAVIGATION_MODE_LIST

getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);

,然后设置一个适配器吧。

and then set an adapter for it.

在列表中显示出来的预期,但我需要改变列表的小三角的颜色作为的默认颜色的是非常接近我的的背景颜色的。

The list show up as expected, but I need to change the 'little triangle' color of the list as the default color is very close to my background color.

是否有可能做到这一点,如果是的话,我该怎么办呢?

Is it possible to do this, if so, how can I do it?

推荐答案

要更改的小三角是一个微调小部件的背景动作条。其背景是一个状态列表绘制。国家列表绘制的项目是9补丁可绘像这样的(这个特殊的一个是华电国际版本,默认状态为全息光主题):

The little triangle you want to change is in the background of a Spinner widget in ActionBar. The background is a state list drawable. Items of the state list drawable are 9-patch drawables like this one (this particular one is the hdpi version for default state for Holo light theme):

要改变你必须改变几集这9个补丁可绘制的三角形的色彩 - 一个可拉伸的状态中的每个DPI和组合。您还需要自定义状态列表绘制是一样的微调构件的背景。

To change the color of the triangle you have to change few sets of these 9-patch drawables - one drawable for each dpi and combination of states. You'll also need custom state list drawable to be as as the background of the Spinner widget.

要更改窗口小部件的背景,你必须调整的主题。如果您使用的是 ActionBarSherlock (ABS)的变化 actionDropDownStyle 项目,并为本地动作条变更机器人:actionDropDownStyle 的项目(即使您使用ABS原生的ActionBar用于运行设备Android 4.0及更高版本)

To change the widget background you have to adjust the theme. If you are using ActionBarSherlock (ABS) change actionDropDownStyle item and for native ActionBar change android:actionDropDownStyle item (even if you use ABS native ActionBar is used for devices running Android 4.0 and higher).

主题应该是这样的:

<style name="MyTheme" parent="SomeParentStyle>
    <item name="actionDropDownStyle">@style/MyActionBarSpinnerStyle</item><!-- if you use ABS -->
    <item name="android:actionDropDownStyle">@style/MyActionBarSpinnerStyle</item>
</style>

MyActionBarSpinnerStyle 应该是这样的:

<style name="MyActionBarSpinnerStyle" parent="@style/MyDropDownActionBarStyle">
    <item name="android:background">@drawable/my_custom_state_list_drawable</item>
</style>

在哪里,而不是 MyDropDownActionBarStyle 应该有类似 Widget.Sherlock.Light.Spinner.DropDown.ActionBar 如果你用ABS或 Widget.Holo.Light.Spinner.DropDown.ActionBar 如果你只针对本地的ActionBar。

Where instead of MyDropDownActionBarStyle there should be something like Widget.Sherlock.Light.Spinner.DropDown.ActionBar if you use ABS or Widget.Holo.Light.Spinner.DropDown.ActionBar if you target only native ActionBar.

这篇关于我怎样才能改变“小三角彩”在行动吧NAVIGATION_MODE_LIST的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆