2016-12-20 22 views
-1

ActionBarの高さに設定されているXMLの余白のために、この灰色のバーを取り除くことはできません。最終的にアクションバーが表示されますが透明ですが、最初からこのグレーの背景を取り除くにはどうすればよいですか? paddingTopを使用すると、アクションバーはクリックできません。灰色の背景余白のためにAndroidのメインコンテンツ

enter image description here

<android.support.v4.widget.DrawerLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/drawer_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="@android:color/transparent" 
     android:orientation="vertical"> 

     <include 
      android:id="@+id/action_bar" 
      layout="@layout/action_bar" /> 

    </RelativeLayout> 

    <FrameLayout 
     android:layout_marginTop="?attr/actionBarSize" 
     android:id="@+id/content_frame" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" /> 

    <ListView android:id="@+id/left_drawer" 
     android:background="#FFFFFF" 
     android:layout_width="240dp" 
     android:layout_height="match_parent" 
     android:layout_gravity="left|start" 
     android:choiceMode="singleChoice"/> 
</android.support.v4.widget.DrawerLayout> 

答えて

0

あなたの引き出し内の他のすべてのレイアウトにRelativeLayout親を使用してください。 そしてそのように、アプリケーションバーの下に滞在することでframeLayoutを設定します。これは動作するはず

<android.support.v4.widget.DrawerLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/drawer_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <RelativeLayout 
      android:id="@+id/action_bar_container" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:background="@android:color/transparent" 
      android:orientation="vertical"> 

      <include 
       android:id="@+id/action_bar" 
       layout="@layout/action_bar" /> 

     </RelativeLayout> 

     <FrameLayout 
      android:id="@+id/content_frame" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_below="@id/action_bar_container" /> 

     <ListView android:id="@+id/left_drawer" 
      android:background="#FFFFFF" 
      android:layout_width="240dp" 
      android:layout_height="match_parent" 
      android:layout_gravity="left|start" 
      android:choiceMode="singleChoice"/> 

    </RelativeLayout> 
</android.support.v4.widget.DrawerLayout> 

、それが見えだ場合にのみ、アクションバーの下枠のレイアウトを移動する必要があります!

+0

LinearLayout –

+0

これはうまくいきましたが、アクションバーのコンテナに 'android:layout_height =" wrap_content "'を作成し、引き出しのListViewを移動しなければなりませんでした。 –

+0

申し訳ありませんが、あなたのコードをコピーして貼り付け、親レイアウトを追加しただけです –

0

Thisは ...あなたを助けるか、カスタムツールバーを追加しようと... below`

<android.support.design.widget.AppBarLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:theme="@style/AppTheme.AppBarOverlay"> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" 
     android:background="?attr/gradient" 
     app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
     app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /> 

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

` とincludeタグでそれを含めるようなコンテンツを持つ別のレイアウトファイルを作ることができます引き出しレイアウトで... findViewById(...)でツールバーを取得し、setSupportActionBar(ツールバーツールバー)メソッドを使用して設定します。

関連する問題