veedzk
veedzk

Reputation: 43

How to change a way Actionbar background is shown?

I am using ActionBar Sherlock and I wanted to change the ActionBar background. I was able to achieve this by modifying my style XML file:

<item name="android:background">@drawable/background_bitmap</item>

The problem is that no matter of device or position (landscape/horizontal) the actionbar background graphic is always stretched as shown here:

Portrait mode:

portrait mode

Landscape mode:

landscape mode

Is there a way to change the way the background_bitmap is shown?

I'd rather the background is either aligned to the left/right or zoomed and cropped.

Upvotes: 2

Views: 1187

Answers (1)

Matthias Robbers
Matthias Robbers

Reputation: 15728

Yes, create a drawable xml like this in /res/drawable/ and reference it as the action bar background drawable.

<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:gravity="right"
    android:src="@drawable/background_bitmap" /> 

Upvotes: 6

Related Questions