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

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

问题描述

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

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

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

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

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

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

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.

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();

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>

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

EDIT: 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.

解决方案

I figured it out! I had to set

app:contentInsetStartWithNavigation="0dp"

in my Toolbar layout.

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

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