Search code examples
androidcontextual-action-bar

Color "splitActionBarWhenNarrow" Bottom Action Bar


I have an MainActivity extends ActionBarActivity , I want to color my action bar I used a custom style , the problem that the custom styles I'm using requires Api 11 At least I tried using:

getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#0099cc"))); 

But the Bottom ActionBar is Not Colored enter image description here

This Is My Style.xml :

<!--
    Base application theme, dependent on API level. This theme is replaced
    by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
    <!--
        Theme customizations available in newer API levels can go in
        res/values-vXX/styles.xml, while customizations related to
        backward-compatibility can go here.
    -->
</style>

<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">

    <!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>


Solution

  • If you want to color your split action bar u will have to use android:backgroundSplit. following code will help you.

        <style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
        <item name="android:background">#9933CC</item>  
        <item name="android:backgroundSplit">#9933CC</item>
        <item name="android:titleTextStyle">@style/myTheme.ActionBar.Text</item>
    
    
    </style>
    
    <style name="myTheme.ActionBar.Text" parent="@android:style/TextAppearance">
        <item name="android:textColor">#FFFFFF</item>
        <item name="android:typeface">monospace</item>
        <item name="android:textStyle">bold</item>
    </style>