1

導航視圖高度我已設置爲match_parent,但它並不完全匹配父級 下面是xml代碼:導航視圖高度我已設置爲match_parent,但它根本不匹配父母

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v4.widget.DrawerLayout 
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:id="@+id/drawer_layout" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:fitsSystemWindows="true" 
tools:openDrawer="start"> 

    <RelativeLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:app="http://schemas.android.com/apk/res-auto" 
     android:orientation="vertical" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

    <FrameLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:id="@+id/content"> 
    </FrameLayout> 

    </RelativeLayout> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 
     <ImageView 
      android:id="@+id/moveimage" 
      android:layout_width="50dp" 
      android:layout_height="50dp" 
      android:src="@drawable/ic_launcher"/> 
    </RelativeLayout> 

    <android.support.design.widget.NavigationView 
     android:id="@+id/nav_view" 
     android:layout_width="50dp" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     android:fitsSystemWindows="true" 
     android:background="#fff" 
     app:headerLayout="@layout/nav_header" /> 
</android.support.v4.widget.DrawerLayout> 

對於navigationView的高度,我怎麼讓它以適應整個屏幕

的截圖是在下面:

enter image description here

+0

相對佈局沒有方向屬性 – Confuse

+0

@Yasharyan什麼是方向屬性所以我應該怎麼改? –

+0

您有2個相對佈局。第一個有'android:orientation =「vertical」'行。去掉它。注意確定這是否修正了一切,但這是不正確的做法。 – Confuse

回答

0

嘗試下面可以幫助你:

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v4.widget.DrawerLayout 
    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:id="@+id/drawer_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    tools:openDrawer="start"> 

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/lytMain" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:orientation="vertical" 
    android:layout_height="match_parent"> 

    <FrameLayout 
     android:id="@+id/frameLayout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     /> 
</LinearLayout> 
<RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="@drawable/side_nav_bar"> 

     <ImageView 
      android:id="@+id/moveimage" 
      android:layout_width="50dp" 
      android:layout_height="50dp" 
      android:src="@mipmap/ic_launcher" /> 
    </RelativeLayout> 
<android.support.design.widget.NavigationView 
    android:id="@+id/nav_view" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_gravity="start" 
    android:fitsSystemWindows="true"/> 

相關問題