My problem is the extra space between the nav-drawer icon and toolbar title. The sample images are below:
The xml view of the toolbar is
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:titleTextAppearance="@style/Toolbar.TitleText"
app:popupTheme="@style/AppTheme.PopupOverlay" />
I have tried to solve this problem by using code below but no change occurred.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
//toolbar.setTitleMarginStart(0);
toolbar.setTitleMarginStart(-8);
}
Is there any way to solve this problem ?
Add
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"
app:contentInsetStartWithNavigation="0dp"
to the ToolBar
.
Complete Code :
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:titleTextAppearance="@style/Toolbar.TitleText"
app:popupTheme="@style/AppTheme.PopupOverlay"
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"
app:contentInsetStartWithNavigation="0dp" />
Add app:contentInsetStartWithNavigation="0dp"
in toolbar
Add this line app:contentInsetStartWithNavigation="0dp"
<android.support.v7.widget.Toolbar
android:id="@+id/share"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:navigationIcon="@drawable/action_back"
app:popupTheme="@style/AppTheme.PopupOverlay"
app:title="@{title}"
android:background="4855b5"
app:titleTextColor="ffffff"
style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"
app:titleTextAppearance="@style/Toolbar.TitleText"
app:contentInsetStartWithNavigation="0dp" />