mrroboaat
mrroboaat

Reputation: 5692

ActionbarSherlock and homeAsUpIndicator

I have the problem to customize the back arrow. I want a red arrow instead of default arrow. I've read many topics about that but it doesn't work.

So i place my styles in res/values/styles.xml. Here is my code :

<style name="AppBaseTheme" parent="Theme.Sherlock.Light">

    <item name="actionBarStyle">@style/Widget.AppTheme.ActionBar</item>
    <item name="homeAsUpIndicator">@drawable/btn_nav_retour</item>

</style>

I can't set "android:homeAsUpIndicator" beacause it requires api level 11 and my min sdk is 9.

Should I set the same code in res/values-v11/styles.xml ?

Thx

Upvotes: 1

Views: 1114

Answers (2)

hardartcore
hardartcore

Reputation: 17037

To work in all API's you should create style.xml in values-v11 and values-v14 folder. In values-v14 for example you should use:

<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
    <item name="android:actionBarStyle">@style/Widget.AppTheme.ActionBar</item>
    <item name="android:homeAsUpIndicator">@drawable/btn_nav_retour</item>
</style>

In default values folder you should use attributes given by ActionBarSherlock, but for higher API levels you should stick with Android default ActionBar attributes and place android: in front of them. In that way it will work for higher API levels.

Upvotes: 3

arne.jans
arne.jans

Reputation: 3856

As a sidenote to the accepted answer: if you don't want to duplicate your Theme for both API-ranges, you could add both items to your AppBaseTheme in values/styles.xml:

<style name="AppBaseTheme" parent="Theme.Sherlock.Light">
    <item name="actionBarStyle">@style/Widget.AppTheme.ActionBar</item>
    <item name="homeAsUpIndicator">@drawable/btn_nav_retour</item>
    <item name="android:homeAsUpIndicator" tools:targetApi="11">@drawable/btn_nav_retour</item>
</style>

The targetApi-attribute prevents the error-message from lint. The xml-item it annotates is ignored by older Android-versions.

Upvotes: 0

Related Questions