Change background color of Tabs in ActionBar in Sherlocks library in Android?

后端 未结 3 851
情话喂你
情话喂你 2021-01-17 05:40

I am working on Actionbar using Sherlock library. I want to change the Background Image of the Actionbar and Tabs differently. Currently I have changed the Background of the

相关标签:
3条回答
  • 2021-01-17 05:51

    Instead of doing that, you can use Style for Tabs:

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <!-- the theme applied to the application or activity -->
        <style name="CustomActivityTheme" parent="@android:style/Theme.Holo">
            <item name="android:actionBarTabTextStyle">@style/CustomTabTextStyle</item>
            <item name="android:actionBarDivider">@drawable/ab_divider</item>
            <item name="android:actionBarItemBackground">@drawable/ab_item_background</item>
        </style>
    
        <!-- style for the action bar tab text -->
        <style name="CustomTabTextStyle" parent="@android:style/TextAppearance.Holo">
            <item name="android:textColor">#2456c2</item>
        </style>
    </resources>
    

    check this article for more details.

    0 讨论(0)
  • 2021-01-17 05:52

    you can use this code:

    actionBar.setStackedBackgroundDrawable(new ColorDrawable(yourColor)); // for example new ColorDrawable(Color.BLUE)
    
    0 讨论(0)
  • 2021-01-17 06:02

    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)
提交回复
热议问题