2017-07-29 4 views
-1

ハンバーガー&のツールバーを使わずに、ActionBarの左パディングを削除したいと思います。私はツールバーを試しましたが、私は欠点であると感じた制限に遭遇しました。 私はAndroidプログラミングの新機能で、デフォルトのActionBarを使用してこれをクリーンなソリューションにしていただきありがとうございます。ハンバーガーとタイトルの間のパディングを削除する

enter image description here

答えて

2

今、あなたにこの

のような活動で、この

<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を設定ツールバー

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

のプロパティ下のこの使用を試してみてください

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