ActionBarSherlock Screen Does Not Repeat on ICS Previews

I am moving my ActionBar application to ActionBarSherlock and I am trying to customize the background using a tiled background. I am testing my code on two real devices, one running Android 2.1 and the other running Android 4.0.4.

The code below works on the ICS device (the background repeats), but not on Eclair (the background is stretched, not repeated). I also tested this on an Android 2.3 emulator, and the background also does not repeat. It seems to tileMode="repeat"work only with ICS.

themes.xml:

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

<style name="Opheodrys.Widget.ActionBar" parent="Widget.Sherlock.Light.ActionBar">
    <item name="android:background">@drawable/ab_background_pattern</item>
    <item name="background">@drawable/ab_background_pattern</item>
</style>

ab_background_pattern.xml:

<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/ab_background_tile"
    android:tileMode="repeat"
    tileMode="repeat" /> <!-- I've added this just in case, but it doesn't seem to be needed -->
+5
source share
1 answer

Android- № 15340, ActionBarSherlock.

- :

BitmapDrawable bg = (BitmapDrawable)getResources().getDrawable(R.drawable.bg_striped);
bg.setTileModeXY(TileMode.REPEAT, TileMode.REPEAT);
getSupportActionBar().setBackgroundDrawable(bg);
+15

All Articles