Search code examples
javaandroidtoolbar

Materialdesign toolbar back arrow not showing in versions before Lollipop


I have setup a custom black back arrow in the themes for the application to be shown on the toolbar as "homeasupindicator" - (I have one themes.xml file for v21 and also a general themes.xml for all lower versions). The relevant code is:

<style name="AppTheme.Base" parent="Theme.AppCompat.NoActionBar">
...
<item name="android:homeAsUpIndicator">@drawable/black_back_arrow</item>
...
</style>

In lollipop this works fine, but in prior versions (e.g. Kitkat) no arrow appears in the toolbar (although the arrow is "still there", i.e. you can click in the location it should be to get the same behavior). What is the problem with this and how can I get my custom arrow to display in prior versions (using themes)?


Solution

  • AppCompat uses

    homeAsUpIndicator

    there is no need for the prefix

    i.e. remove android:

    The prefix is used for the native platform's implementation and because AppCompat comes fro mthe support library it uses another attribute (namely the same but without a prefix).