Ric*_*ral 5 android background-repeat actionbarsherlock
我正在将我的应用程序的ActionBar移动到ActionBarSherlock,我正在尝试使用平铺背景自定义背景.我在2个真实设备上测试我的代码,一个运行Android 2.1,另一个运行Android 4.0.4.
下面的代码是在ICS设备上工作(背景重复)但不在Eclair上(背景被拉伸而不是重复).我也在Android 2.3模拟器上测试了它,背景也不重复.它似乎tileMode="repeat"只适用于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>
Run Code Online (Sandbox Code Playgroud)
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 -->
Run Code Online (Sandbox Code Playgroud)
Jak*_*ton 15
这是Android bug#15340而不是ActionBarSherlock错误.
您可以通过以下类似方法解决此问题:
BitmapDrawable bg = (BitmapDrawable)getResources().getDrawable(R.drawable.bg_striped);
bg.setTileModeXY(TileMode.REPEAT, TileMode.REPEAT);
getSupportActionBar().setBackgroundDrawable(bg);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1715 次 |
| 最近记录: |