Actionbarsherlock background image

南楼画角 提交于 2019-12-11 23:32:43

问题


Having some trouble overriding ActionBarSherlock styles, hopefully someone can help. I have created a drawable like so:

(in res/drawable/actionbar_background.xml)

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

Then in my app's style file (in res/values/style.xml)

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="ActionBar" parent="@android:style/Widget.Holo.ActionBar">
    <item name="android:background">@drawable/actionbar_background</item>
</style>
<style name="my_theme" parent="@style/Theme.Sherlock.Light">
        <item name="android:actionBarStyle">@style/ActionBar</item>
    </style>
</resources>

The result is that the Theme.Sherlock.Light style is picked up (or Theme.Sherlock if I swap it), but I don't get any change in style to the actionbar's background itself.

Thanks


回答1:


This should give you the Theme.Sherlock.Light style with your custom action bar background:

<style name="ActionBar" parent="Theme.Sherlock.Light">
    <item name="abBackground">@drawable/actionbar_background</item>
</style>

Put it in your res/values/style.xml file and declare your style to be @style/ActionBar in your manifest.

More info - http://actionbarsherlock.com/theming.html




回答2:


For version 4.0+, you can simply use the "background" item name.

<style name="ActionBar" parent="Theme.Sherlock.Light">
    <item name="background">@drawable/actionbar_background</item>
</style>


来源:https://stackoverflow.com/questions/9156996/actionbarsherlock-background-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!