Change ActionBar Tabs background color

前端 未结 5 647
鱼传尺愫
鱼传尺愫 2020-12-18 23:23

Is there a way to change the background color of the tab bar in the ActionBar without changing it in the one line version?

To clarify what I want: In portrait mode t

相关标签:
5条回答
  • 2020-12-18 23:58

    To seperate styles depending on orientation you have to create in your /res folder a new folder called layout-land (for landscape mode) and layout-port (in portrait mode) and put your xml files for action bar and set it's specific style (with the color you want) on each folder.

    0 讨论(0)
  • 2020-12-19 00:08

    I think you are looking for the android:backgroundStacked attribute of the ActionBar style:

    <style name="MyTheme" parent="android:Theme.Holo.Light">
        <item name="android:actionBarStyle">@style/MyActionBarStyle</item>
    </style>
    
    <style name="MyActionBarStyle" parent="@android:style/Widget.Holo.Light.ActionBar.Solid">
        <item name="android:backgroundStacked">@drawable/my_stacked_background</item>
    </style>
    

    or (If using ActionBarSherlock):

    <style name="MyTheme" parent="@style/Theme.Sherlock.Light">
        <item name="android:actionBarStyle">@style/MyActionBarStyle</item>
        <item name="actionBarStyle">@style/MyActionBarStyle</item>
    </style>
    
    <style name="MyActionBarStyle" parent="@style/Widget.Sherlock.Light.ActionBar.Solid">
        <item name="android:backgroundStacked">@drawable/my_stacked_background</item>
        <item name="backgroundStacked">@drawable/my_stacked_background</item>
    </style>
    
    0 讨论(0)
  • 2020-12-19 00:09

    To Change Actionbar Tab's color, Pls use this code:

    //For Example if you want White color as Tabs background, then

    getActionBar().setStackedBackgroundDrawable(new ColorDrawable(Color.parseColor("#FFFFFF")));
    
    0 讨论(0)
  • 2020-12-19 00:09

    In ActionBarSherlock's values/abs__themes.xml there is

    <item name="actionModeSplitBackground">@drawable/abs__cab_background_bottom_holo_dark</item>
    

    You have to create your own theme derived from ABS

    <style name="AppTheme" parent="Theme.Sherlock">
        <item name="actionBarStyle">@style/MyActionBar</item>
        <item name="android:actionBarStyle">@style/MyActionBar</item>
    </style>
    
    <style name="MyActionBar" parent="Widget.Sherlock.ActionBar">
        <item name="actionModeSplitBackground">@drawable/my_split_background</item>
    </style>
    

    Hope this helps you.

    0 讨论(0)
  • 2020-12-19 00:14
    ColorDrawable colorDrawable = new ColorDrawable(Color.White);
    actionBar.SetStackedBackgroundDrawable(colorDrawable);
    

    for xamarin folks.

    0 讨论(0)
提交回复
热议问题