Search code examples
androidandroid-layoutandroid-actionbaractionbarsherlock

android - two color Action Bar background


I'm using ActionbarSherlock. I need to create a background style for the Action Bar as image below.

action bar image

I can create a plain color background style with a 9-patch image, but this seems quite complex to me. please give me a clue to achieve this.


Solution

  • Create 9-patch graphics for all action bar heights, that is 48 dp (portrait), 40 dp (landscape) and 56 dp (tablet). Provide the graphics at least in xhdpi.

    Here is the graphic for phone, portrait (xhdpi). Rename to ab_bg.9.png

    9-patch

    <style name="AppTheme" parent="Theme.Sherlock">
        <item name="actionBarStyle">@style/Styled.ActionBar</item>
        <item name="android:actionBarStyle">@style/Styled.ActionBar</item>
    </style>
    
    <style name="Styled.ActionBar" parent="@style/Widget.Sherlock.ActionBar">
        <item name="android:background">@drawable/ab_bg</item>
    </style>