簡體   English   中英

ActionBar選項卡指示器顏色

[英]ActionBar Tab indicator color

我想知道如何更改選項卡指示器顏色。 我嘗試了多個代碼,但是沒有一個工作,所以請幫助我如何更改默認顏色? 下面的代碼我正在使用:

actionBar.setStackedBackgroundDrawable(getResources()
                        .getDrawable(R.drawable.tab_selector));

tab_selector.xml

->->->

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

<!-- Pressed -->
<item android:state_selected="true" android:state_pressed="true" android:drawable="@color/tabcolor" />
<item android:state_pressed="true" android:drawable="@color/tabcolor" />

制作自定義操作欄。 使用此http://jgilfelt.github.io/android-actionbarstylegenerator/

使用樣式也可以做到這一點(代碼基於support-v7庫)

    <style name="MyAppTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">

             <item name="android:actionBarTabStyle">@style/MyActionBarTabs</item> 
             <item name="actionBarTabStyle">@style/MyActionBarTabs</item>

    </style>

    <style name="MyActionBarTabs" parent="@style/Widget.AppCompat.ActionBar.TabView">

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

    </style>

有關更多信息,請訪問官方文檔:樣式欄

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM