简体   繁体   中英

Android ActionBar Tabs background color split mode

Hee,

First of all I want to say that I am using ActionBarSherlock (the screenshots are taken on a Samsung Galaxy S3).

I have an actionbar with a tabbar in it, I want that the tabbar has a grey color when it is splitted (the tabbar is underneath the actionbar) and a transparant color (or same color as actionbar background) when the tabbar is inside the actionbar.

Here is a little code snippit of my styles.xml:

<style name="Theme.OSP.Light" parent="@style/Theme.Sherlock.Light">
        <item name="actionBarStyle">@style/Widget.Styled.ActionBar</item>
        <item name="android:actionBarStyle">@style/Widget.Styled.ActionBar</item>

        <item name="actionBarTabBarStyle">@style/Widget.Styled.ActionBar.TabBar</item>
        <item name="android:actionBarTabBarStyle">@style/Widget.Styled.ActionBar.TabBar</item>
    </style>

    <style name="Widget.Styled.ActionBar" parent="Widget.Sherlock.Light.ActionBar">        
        <item name="android:background">#F0F0F0</item>
        <item name="background">#F0F0F0</item>
    </style>

    <style name="Widget.Styled.ActionBar.TabBar" parent="Widget.Sherlock.Light.ActionBar.TabBar">
        <item name="android:background">#E0E0E0</item>
        <item name="android:gravity">center</item>
    </style>

Below are some screenshots to make my question more clear.

Landscape (actionbar not splitted). This is not OK, the tabbar should have the same color as the actionbar, but instead it has the same grey color: 风景(动作栏不分割)

Portrait (actionbar splitted). This is OK, the tabbar has a grey color in this state: 肖像(动作栏被分割)

I've found a wonderful website were you can generate an android theme in seconds! This solved all my problems:

http://jgilfelt.github.com/android-actionbarstylegenerator/

EDIT

Also see the following link for a working answer: Change ActionBar Tabs background color

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM