0

所以我只想更改应用程序中选项卡小部件的蓝线颜色。我在网上搜索并找到了更改选项卡整个背景的解决方案,但我只想将选项卡小部件的蓝线颜色更改为另一种颜色,如黑色。可以这样做吗?

蓝线

4

2 回答 2

0

你可以试试这种风格:

<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <!-- Non focused states -->
    <item android:state_focused="false"
            android:state_selected="false"
            android:state_pressed="false" 
            android:drawable="@drawable/tab_unselected_holo" />

    <item android:state_focused="false"
            android:state_selected="true"
            android:state_pressed="false"
            android:drawable="@drawable/tab_selected_holo" />

    <!-- Focused states -->
    <item android:state_focused="true"
            android:state_selected="false"
            android:state_pressed="false"
            android:drawable="@drawable/tab_unselected_focused_holo" />

    <item android:state_focused="true"
            android:state_selected="true"
            android:state_pressed="false"
            android:drawable="@drawable/tab_selected_focused_holo" />

    <!-- Pressed -->
    <!--    Non focused states -->
    <item android:state_focused="false"
            android:state_selected="false"
            android:state_pressed="true"
            android:drawable="@drawable/tab_unselected_pressed_holo" />

    <item android:state_focused="false"
            android:state_selected="true"
            android:state_pressed="true"
            android:drawable="@drawable/tab_selected_pressed_holo" />

    <!--    Focused states -->
    <item android:state_focused="true"
            android:state_selected="false"
            android:state_pressed="true"
            android:drawable="@drawable/tab_unselected_pressed_holo" />

    <item android:state_focused="true"
            android:state_selected="true"
            android:state_pressed="true"
            android:drawable="@drawable/tab_selected_pressed_holo" />

</selector>

您也可以访问此链接

希望它会帮助你。

于 2013-07-17T05:03:04.243 回答
0

在您的自定义主题中为您的 tabwidget 创建一个单独的样式。

尝试如下:

<item name="android:tabWidgetStyle">@android:style/Widget.TabWidget</item> 

<style name="Widget.TabWidget">
        <item name="android:textAppearance">@style/TextAppearance.Widget.TabWidget</item>
        <item name="android:ellipsize">marquee</item>
        <item name="android:singleLine">true</item>
</style>  


<style name="TextAppearance.Widget.TabWidget">
    <item name="android:textSize">14sp</item>
    <item name="android:textStyle">normal</item>
    <item name="android:textColor">@android:color/tab_indicator_text</item>
</style>     

我希望这对你有帮助。

于 2013-07-17T05:47:21.817 回答