0

我正在向我正在编写的测试应用程序添加一个操作栏,并且我在整个 stackoverflow 中都看到了关于此的问题,但对我没有任何帮助。根据本指南:

http://android-developers.blogspot.com/2011/04/customizing-action-bar.html

我正在尝试更改我在操作栏上使用的选项卡的选择颜色。默认为淡蓝色。就像我做的测试一样:

<style name="CustomTab" parent="android:style/Widget.Holo.Light.ActionBar.TabView">
    <item name="android:background">#000000</item>
</style>

这给了我一个完全纯黑色的标签,而不是选择器部分。有人可以帮助更好地指导我吗?我似乎无法在任何地方找到一个好的例子。

4

1 回答 1

1

首先,您必须定义一个选择器 xml 文件,然后在此处编写此代码并用此替换您的代码

item name="android:background">@drawable/yourfilename</item>

和选择器 xml

<?xml version="1.0" encoding="utf-8"?>
<selector
    xmlns:android="http://schemas.android.com/apk/res/android"
>
    <item
        android:state_pressed="true"
        android:drawable="@drawable/picture_selected" />
    <item
        android:state_focused="true"
        android:drawable="@drawable/picture_selected" />
    <item
        android:drawable="@drawable/picture_unselected" />
</selector>
于 2012-11-30T17:17:26.610 回答