1

enter image description here

Top is the default padding for the upnavigation arrow when you set

getSupportActionBar().setDisplayHomeAsUpEnabled(true);

I would like the Toolbar to look more like the bottom image, as I want the title to indicate where the upnavigation arrow will send the user to rather than being a description of the current activity. So far I have tried adding a custom textview to the toolbar, and setting app:contentInsetStartWithNavigation="0dp" as per this similar question. But as the author notes, this doesn't remove the padding to the right of the arrow. How can I get the toolbar to look more like the second image? Current xml for my toolbar is as follows:

<android.support.v7.widget.Toolbar
    android:id="@+id/toolbar_doc"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="?attr/colorPrimary"
    android:minHeight="?attr/actionBarSize"
    android:theme="?attr/actionBarTheme"
    app:contentInsetStartWithNavigation="0dp"
    app:layout_constraintTop_toTopOf="parent">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentLeft="true"
        android:gravity="left"
        android:id="@+id/txtTitle"
        android:textColor="#FFFFFF"/>

</android.support.v7.widget.Toolbar>

I further provide the xml for the menu, which I add to the toolbar using the menu inflater. Another solution I was floating around was adding an arrow icon and textview to the menu itself? But then I'm not sure how I'd give the new arrow icon the same upnavigation behavior.

<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    <item
        android:id="@+id/navigation_home"
        android:icon="@drawable/ic_baseline_home_24px"
        app:showAsAction="always"/>
    <item
        android:id="@+id/action_settings"
        android:orderInCategory="100"
        android:title="@string/action_settings"
        app:showAsAction="never" />
</menu>
Terry Martin
  • 529
  • 8
  • 20

1 Answers1

2

Try setting app:contentInsetStart to 0dp instead of app:contentInsetStartWithNavigation.

    <android.support.v7.widget.Toolbar
        ...
        app:contentInsetStart="0dp">
VIN
  • 6,385
  • 7
  • 38
  • 77
  • 1
    This results in the same spacing as with `app:contentInsetStartWithNavigation="0dp"`. I also tried setting `app:contentInsetLeft="0dp"` – Terry Martin Aug 08 '18 at 00:41