在Android工具栏中删除汉堡包(菜单)图标后的大填充? [英] Remove large padding after hamburger (menu) icon in Android Toolbar?

查看:119
本文介绍了在Android工具栏中删除汉堡包(菜单)图标后的大填充?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是菜单图标后的大填充间隙的图片:

Here is a picture of the large padding gap after the menu icon:

这是我一个月(夏季学校)不从事项目工作后发生的.我刚回到它时,发现更新Android Studio后,工具栏上的间隙比正常情况大.我在SO上找不到关于此的任何问题/解决方案.如果有人可以提供帮助,将不胜感激.

This occurred after not working on my project for a month (summer school). I just came back to it and noticed this larger than normal gap on the toolbar after I updated Android Studio. I can't find any questions/solutions about this on SO. If anyone can help that would be very much appreciated.

我这样做是在加载汉堡包图标(每行都正确放置在应用程序中,无论是在类声明中,还是在onCreate()等中,为了简单起见,我都这样表示):

I am loading the hamburger icon by doing this (each line is properly placed in the app, in either the class declaration, onCreate(), etc. I put it like this for simplicity.):

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

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

Here is the xml code for my toolbar:

<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属性,但是没有一个影响菜单图标后的间距.

I tried messing around with the various contentInset xml attributes but none affected the spacing after the menu icon.

链接显示了我曾经拥有的内容(位于页面中间) .如果您注意到标题和汉堡图标之间的间距,则间距不如此处所示的图片宽.好像间距增加了一倍之类.

This link shows what I used to have (found around the middle of the page). If you notice the spacing between the title and the hamburger icon, the spacing is not as wide as in the picture shown here. It's as if the spacing got doubled or something.

推荐答案

我知道了!我必须设置

app:contentInsetStartWithNavigation="0dp"

在我的Toolbar布局中.

这篇关于在Android工具栏中删除汉堡包(菜单)图标后的大填充?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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