android - 删除Android工具栏中汉堡包(菜单)图标后的大填充?

标签 android android-toolbar

这是菜单图标后的大填充间隙的图片: enter image description here

这发生在我的项目一个月没有工作(暑期学校)之后。在我更新 Android Studio 后,我刚刚回到它并注意到工具栏上的这个间隙比正常情况要大。我在 SO 上找不到任何关于此的问题/解决方案。如果有人可以提供帮助,将不胜感激。

我正在通过这样做加载汉堡包图标(每一行都正确放置在应用程序中,在类声明、onCreate() 等中。为了简单起见,我这样写。):

ActionBarDrawerToggle mDrawerToggle;
mDrawerToggle = new ActionBarDrawerToggle(getActivity(), dl, toolbar, R.string.nav_open, R.string.nav_closed)
mDrawerToggle.syncState();

这是我的工具栏的 xml 代码:

<android.support.v7.widget.Toolbar
    android:id="@+id/toolbar"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:minHeight="?attr/actionBarSize"
    app:layout_scrollFlags="scroll|enterAlways"
    app:title="Test Title">

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

我尝试弄乱各种 contentInset xml 属性,但没有影响菜单图标后的间距。

编辑:这个 link显示我曾经拥有的东西(在页面中间找到)。如果您注意到标题和汉堡图标之间的间距,则间距没有此处显示的图片那么宽。好像间距增加了一倍之类的。

最佳答案

我想通了!我必须设置

app:contentInsetStartWithNavigation="0dp"

在我的 Toolbar 布局中。

enter image description here

关于android - 删除Android工具栏中汉堡包(菜单)图标后的大填充?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38373481/

相关文章:

android - 有没有办法让两个 Activity 同时使用相同的背景?

android - 为什么 Android Studio 中不显示layout_gravity 属性?

android - 是否可以在运行时设置工具栏的样式?

android - 抽屉导航、工具栏和回收器在同一个 xml 布局文件中查看所有内容?

android - 无法解析 : com. android

android - 无法从相机解码位图文件

java - 宽高比为 800x480

android - 为什么 CollapsingToolbarLayout 在扩展内容下放置一个空白空间

Android App 的工具栏标题未垂直居中

android - android SDK 平台包有什么用?