簡體   English   中英

在Android工具欄中刪除漢堡包(菜單)圖標后的大填充?

[英]Remove large padding after hamburger (menu) icon in Android Toolbar?

這是菜單圖標后面的大填充間隙的圖片: 在此輸入圖像描述

這是在我的項目沒有工作一個月(暑期學校)后發生的。 我剛剛回到它並注意到我更新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屬性但沒有影響菜單圖標后的間距。

編輯:此鏈接顯示我曾經擁有的(在頁面中間找到)。 如果您注意到標題和漢堡圖標之間的間距,則間距不會像此處所示的圖片那樣寬。 這就好像間距增加了一倍。

我想到了! 我必須設置

app:contentInsetStartWithNavigation="0dp"

在我的Toolbar布局中。

在此輸入圖像描述

將這些屬性添加到Toolbar

app:contentInsetLeft="0dp" 
app:contentInsetStart="0dp" 
app:contentInsetStartWithNavigation="0dp"

這將禁用Toolbar標題的插入開始填充

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM