I have a toolbar that exists across fragments. The first fragment has no up navigation, but when I navigate to the second fragment I make the "up" arrow appear (to go back to the first fragment). However, when I go back to the first fragment and the up arrow disappears, there is a ton of padding to the left of the title. (The gif loops, watch for the 'Fragment 1' title to be spaced far from the left)
I think this has something to do with having android:animateLayoutChanges="true" set on my toolbar, because if I remove that line the padding disappears:
I can't figure out the cause of this, if anyone has a solution that may be able to help I would really appreciate it; whether that be finding a different way to animate the toolbar, or how to get rid of the padding.
Here are the things I've tried so far:
- Getting the relative position of the title text before the fragment transition, then doing
toolbarTitle.setLeft(oldLeft), but theoldLeftvalue is never set. - Trying to remove the padding from the toolbar by putting
app:contentInsetLeft="0dp" app:contentInsetStart="0dp"in my toolbar definition, but this only removes 16dp of padding.
I don't think it matters, but here is my toolbar code. I populate the actions in each fragment's onCreateOptionsMenu.
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:animateLayoutChanges="true"
app:theme="@style/ToolBarStyle">
<TextView
style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"
android:id="@+id/toolbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="DEFAULT"
android:gravity="start"
android:textColor="@color/white" />

