试图改变tabawidget的蓝线颜色

时间:2013-07-17 04:53:31

标签: android android-layout

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

the blue lines

2 个答案:

答案 0 :(得分: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>

您也可以访问This Link

希望它会对你有所帮助。

答案 1 :(得分: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>     

我希望这对你有所帮助。