如何缩小导航图标和工具栏标题之间​​的距离? [英] How to reduce the gap between navigation icon and toolbar title?

查看:155
本文介绍了如何缩小导航图标和工具栏标题之间​​的距离?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是导航抽屉图标和工具栏标题之间​​有多余的空间.示例图片如下:

My problem is the extra space between the nav-drawer icon and toolbar title. The sample images are below:

工具栏的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" />

我试图通过使用下面的代码来解决此问题,但是没有发生任何变化.

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 ?

推荐答案

添加

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" />

这篇关于如何缩小导航图标和工具栏标题之间​​的距离?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆