开发者

ActionBar Sherlock - Backgroundimage in Actionbar

开发者 https://www.devze.com 2023-03-31 18:33 出处:网络
I would love to set a Backgroundimage to the ActionBar which I imported with the \"ActionBar Sherlock\" library. However I can\'t find any link on the internet on how to distinctively set an Backgrou开

I would love to set a Backgroundimage to the ActionBar which I imported with the "ActionBar Sherlock" library. However I can't find any link on the internet on how to distinctively set an Backgrou开发者_运维百科ndImage with XML.

Does anybody here have a hint which he could give me :)?


You create a style for your actionbar, it has to inherit Theme.Sherlock or Theme.Sherlock.Light.

Then link to your image in the attribute abBackground.

Assuming you have an image called myBackgroundImage in res/drawable your style xml would be:

<style name="Actionbar" parent="Theme.Sherlock">
    <item name="abBackground">@drawable/myBackgroundImage</item>
</style>

You can find more attributes for the actionbar here: ActionBarSherlock - Theming

More on styles is found here: Styles and Themes | Android Developers


In your style.xml file add a custom style like this:

<style name="MyActionBarStyle" parent="Widget.Sherlock.ActionBar.TabBar">
        <item name="android:background">@drawable/actionbar_tab_bg</item>

    </style>

and add this style to your app theme with this to lines, the first for the Android <3.0 and the second for the >3.0

<style name="ReservasAppTheme" parent="@style/Theme.Sherlock.Light">
        <item name="actionBarTabStyle">@style/MyActionBarStyle</item>
        <item name="android:actionBarTabStyle">@style/MyActionBarStyle</item>
        </style>

You should add this style to the application tag in manifest


you might want to look at : http://actionbarsherlock.com/theming.html

0

精彩评论

暂无评论...
验证码 换一张
取 消