I have a custom toolbar. But for some reason, at 4.1 the resource up arrow will not be shown. The touch area still exists and it works, but the asset will not be displayed.
Here is the code that the toolbar creates. (The toolbar is installed elsewhere in my base activity)
public ActionBar(AppCompatActivity activity) {
Toolbar toolbar = (Toolbar) activity.findViewById(R.id.toolbar);
toolbar.findViewById(R.id.header_layout).setVisibility(View.GONE);
actionBar = activity.getSupportActionBar();
savedDisplayOptions = actionBar.getDisplayOptions();
savedTitle = actionBar.getTitle();
actionBar.setDisplayShowCustomEnabled(false);
actionBar.setDisplayShowTitleEnabled(true);
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeAsUpIndicator(R.drawable.up_button);
actionBar.setDisplayShowHomeEnabled(false);
}
Here are the xml buttons. As you can see, I have a bug fix with an action bar in 4.1 (I tried to remove it to no avail)
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:left="@dimen/double_spacing"
android:right="@dimen/double_spacing">
<shape>
<size android:height="@dimen/standard_icon_size" android:width="@dimen/standard_icon_size"/>
<solid android:color="@color/transparent"/>
</shape>
</item>
<item
android:left="@dimen/double_spacing">
<bitmap android:src="@drawable/ic_up_arrow" android:gravity="left"/>
</item>
Finally, this is what my toolbar looks like.
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="@dimen/action_bar_height"
android:elevation="@dimen/half_spacing"
app:theme="@style/ToolbarTheme"
android:background="@color/white"
tools:ignore="UnusedAttribute">
<com.mypackage.core.view.TextView
android:id="@+id/standard_toolbar_title"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:ellipsize="end"
android:maxLines="1"
style="@style/H5.Blue" />
<com.mypackage.util.graphics.ActionBarView
android:id="@+id/max_header_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"/>
</android.support.v7.widget.Toolbar>
An interesting thing I just discovered. If I remove the gravity attribute from the bitmap in the up_button xml file, the arrow will appear, but stretch out a lot. If I then remove the transparent element, it will disappear again.