Как уменьшить разрыв между значком навигации и заголовком панели инструментов?
Моя проблема - дополнительное пространство между значком навигатора и заголовком панели инструментов. Образцы изображений ниже:
![spacing between nav-drawer icon and title]()
![spacing between back icon and toolbar]()
Представление xml панели инструментов
<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" />
Я попытался решить эту проблему, используя код ниже, но никаких изменений не произошло.
@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);
}
Есть ли способ решить эту проблему?
Ответы
Ответ 1
Добавить
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"
app:contentInsetStartWithNavigation="0dp"
в ToolBar
.
Полный код:
<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" />