2017-07-29 64 views
-1

我想刪除操作欄中漢堡包&之間的左填充而不必使用工具欄。我嘗試過工具欄,但遇到了我覺得有缺點的限制。 我是Android編程的新手,並希望能夠使用默認的ActionBar來乾淨利落地解決這個問題。刪除漢堡包和標題之間的填充

enter image description here

回答

2

試試下面的工具欄

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

現在設置你toolbar這樣

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 

<android.support.design.widget.AppBarLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" 
     android:background="?attr/colorPrimary" 
     app:popupTheme="@style/AppTheme.PopupOverlay" 
     app:contentInsetLeft="0dp" 
     app:contentInsetStart="0dp" 
     app:contentInsetStartWithNavigation="0dp" /> 

</android.support.design.widget.AppBarLayout> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical"> 

    // add here all your controlls 
</LinearLayout> 

</android.support.design.widget.CoordinatorLayout> 

現在設置工具欄上的活動這樣

財產這種使用
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 
    setSupportActionBar(toolbar); 

問我的情況下,任何的查詢

+0

感謝您的答覆。 Kinly闡述了以下應用:titleTextAppearance =「@ style/Toolbar.TitleText」 app:popupTheme =「@ style/AppTheme.PopupOverlay」 – jmsiox

+0

@jmsiox沒有讓你..? –

+0

我堅持爲工具欄添加樣式,因爲我的文本在更改爲工具欄後現在不可見。 – jmsiox