2016-05-26 5 views
0

に表示されるDrawerLayoutのトップパディングを削除します。基本的には、私はカスタムメニューでdrawerLayoutを実装しています(navigationViewの代わりにrecyclerViewを使用しています)。私がアンドロイド(>ロリポップ)の最新バージョンでアプリを実行するとトップパディングが表示されます。上の詰め物を取り除くのにとにかくありますか?私はdrawerLayoutにfitSystemWindows=trueを設定しようとしましたが、役に立たなかった。apiバージョン> 21

コード

<android.support.v4.widget.DrawerLayout 
     xmlns:app="http://schemas.android.com/apk/res-auto" 
     xmlns:tools="http://schemas.android.com/tools" 
     android:id="@+id/drawer_layout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:fitsSystemWindows="true" 
     tools:openDrawer="start"> 

     <include 
      layout="@layout/app_bar_store_landing" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" /> 

     <android.support.v4.widget.NestedScrollView 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_gravity="start" 
      android:fitsSystemWindows="true"> 
      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:orientation="vertical"> 

       <RelativeLayout 
        android:layout_width="match_parent" 
        android:layout_height="50dp" 
        android:background="@color/drawer_bg" 
        android:paddingLeft="20dp"> 
        <ImageView 
         android:id="@+id/menuIcon" 
         android:layout_width="35dp" 
         android:layout_height="35dp" 
         android:layout_centerVertical="true" 
         android:src="@drawable/location_menu" 
         android:layout_marginRight="10dp"/> 

        <LinearLayout 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:orientation="vertical" 
         android:layout_centerVertical="true" 
         android:layout_toRightOf="@+id/menuIcon"> 
         <TextView 
          android:layout_width="match_parent" 
          android:layout_height="wrap_content" 
          android:text="Jalan Tunku Ismail" 
          android:textColor="@android:color/white" 
          android:ellipsize="end" 
          android:singleLine="true" 
          android:textStyle="bold"/> 
         <TextView 
          android:layout_width="match_parent" 
          android:layout_height="wrap_content" 
          android:text="Tap to change location" 
          android:textColor="@color/grey_text" /> 
        </LinearLayout> 
       </RelativeLayout> 


       <RelativeLayout 
        android:layout_width="match_parent" 
        android:layout_height="50dp" 
        android:background="@color/drawer_bg" 
        android:paddingLeft="20dp"> 
        <ImageView 
         android:id="@+id/menuIcon2" 
         android:layout_width="35dp" 
         android:layout_height="35dp" 
         android:layout_centerVertical="true" 
         android:src="@drawable/store_menu" 
         android:layout_marginRight="10dp"/> 
        <LinearLayout 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:orientation="vertical" 
         android:layout_centerVertical="true" 
         android:layout_toRightOf="@+id/menuIcon2"> 
         <TextView 
          android:layout_width="match_parent" 
          android:layout_height="wrap_content" 
          android:text="Jaya Grocer, Kuala Lumpur" 
          android:textColor="@android:color/white" 
          android:ellipsize="end" 
          android:singleLine="true" 
          android:textStyle="bold"/> 
         <TextView 
          android:layout_width="match_parent" 
          android:layout_height="wrap_content" 
          android:text="Tap to change store" 
          android:textColor="@color/grey_text" /> 
        </LinearLayout> 
       </RelativeLayout> 

       <RelativeLayout 
        android:layout_width="match_parent" 
        android:layout_height="50dp" 
        android:background="@color/drawer_bg" 
        android:paddingLeft="20dp"> 
        <ImageView 
         android:id="@+id/menuIcon3" 
         android:layout_width="35dp" 
         android:layout_height="35dp" 
         android:src="@drawable/my_account" 
         android:layout_centerVertical="true" 
         android:layout_marginRight="10dp"/> 
        <LinearLayout 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:orientation="vertical" 
         android:layout_centerVertical="true" 
         android:layout_toRightOf="@+id/menuIcon3"> 
         <TextView 
          android:layout_width="match_parent" 
          android:layout_height="wrap_content" 
          android:text="My Account" 
          android:textColor="@android:color/white" 
          android:ellipsize="end" 
          android:singleLine="true" 
          android:textStyle="bold"/> 
        </LinearLayout> 
       </RelativeLayout> 

       <RelativeLayout 
        android:layout_width="match_parent" 
        android:layout_height="50dp" 
        android:background="@color/drawer_bg" 
        android:paddingLeft="20dp"> 
        <ImageView 
         android:id="@+id/menuIcon4" 
         android:layout_width="35dp" 
         android:layout_height="35dp" 
         android:layout_centerVertical="true" 
         android:src="@drawable/my_shopping_list" 
         android:layout_marginRight="10dp"/> 
        <LinearLayout 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:orientation="vertical" 
         android:layout_centerVertical="true" 
         android:layout_toRightOf="@+id/menuIcon4"> 
         <TextView 
          android:layout_width="match_parent" 
          android:layout_height="wrap_content" 
          android:text="My Shopping List" 
          android:textColor="@android:color/white" 
          android:ellipsize="end" 
          android:singleLine="true" 
          android:textStyle="bold"/> 
        </LinearLayout> 
       </RelativeLayout> 

       <View 
        android:layout_width="match_parent" 
        android:layout_height="1dp" 
        android:background="@color/grey_text" /> 

       <android.support.v7.widget.RecyclerView 
        android:id="@+id/menuList" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent"/> 
      </LinearLayout> 
     </android.support.v4.widget.NestedScrollView> 
    </android.support.v4.widget.DrawerLayout> 

スクリーンショット:

左 - Lolliop、右 - 固定キットカット enter image description here

NestedScrollViewのandroid:fitsSystemWindows="true"を削除すると、問題が解決します。

+0

任意のレイアウト内にappbar( ')を入れてみてください(相対レイアウトが優先されますmore) – Krups

+0

この行をdimens.xmlに追加してください。" 0dp "と入力してもう一度お試しください。 – Sabari

+0

@Krups - 利用できません。 –

答えて

1

OK、このバグを見つけました。 NestedScrollViewの犯人はandroid:fitsSystemWindows="true"です。この行を削除し、私の問題を解決します。私はアンドロイドの古いバージョン(< Kitkat)に影響していないのはなぜだろうかと思っています。

関連する問題