1

我有一個導航抽屜有三個部分,頂部,中部和底部我需要使中間部分可以滾動。使Android導航抽屜可滾動

enter image description here

這是我目前的佈局。

<?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"> 

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

    <android.support.design.widget.NavigationView 
     android:id="@+id/navigation_drawer_container" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:layout_gravity="start"> 
<!-- begin Top Section--> 
     <android.support.design.widget.NavigationView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="@color/background_black" 
      android:paddingLeft="50dp" 
      app:headerLayout="@layout/nav_header_main" 
      /> 
<!--End Top Section-->  
<!-- begin Middle Section-->  
        <android.support.design.widget.NavigationView 
         android:id="@+id/navigation_drawer_top" 
         android:layout_width="wrap_content" 
         android:layout_height="match_parent" 
         android:layout_gravity="top" 
         android:background="@color/menuColor" 
         android:paddingLeft="50dp" 
         app:itemTextAppearance="@style/NavigationDrawerStyle" 
         app:menu="@menu/menu_navigation_drawer_top" 
         app:itemTextColor="@color/menuTextColour" /> 
<!-- End Middle Section--> 
<!-- begin Bottom Section-->   
     <android.support.design.widget.NavigationView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="bottom" 
      android:background="@color/background_black" 
      app:headerLayout="@layout/nav_group_line" 
      app:itemTextColor="@color/menuTextColour"> 

      <android.support.design.widget.NavigationView 
       android:id="@+id/navigation_drawer_bottom" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="bottom" 
       android:background="@color/menuColor_bottom" 
       android:paddingLeft="50dp" 
       app:itemTextAppearance="@style/NavigationDrawerStyle" 
       app:itemTextColor="@color/menuTextColour" 
       app:menu="@menu/menu_navigation_drawer_bottom" /> 
     </android.support.design.widget.NavigationView> 
<!-- End Bottom Section-->  

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

我如何才能讓染指部分scorll,能夠在我的導航視圖。

回答

1

NavigationView爲您提供attr應用程序:headerLayout,用於添加導航標題。 對於添加頁腳只是包裝所需的頁腳視圖在NavigationView,

<RelativeLayout 
    android:layout_width="wrap_content" 
    android:layout_height="match_parent" 
    android:layout_gravity="start" 
    > 

    <LinearLayout 
     android:background="@android:color/darker_gray" 
     android:clickable="true" 
     android:id="@+id/ll_header" 
     android:layout_height="wrap_content" 
     android:layout_width="match_parent" 
     android:orientation="vertical"> 

     <TextView 
      android:gravity="center" 
      android:id="@+id/nav_header_textview" 
      android:layout_height="48dp" 
      android:layout_width="match_parent" 
      android:text="Your Header Text Here" /> 

    </LinearLayout> 

    <android.support.design.widget.NavigationView 
     android:layout_below="@+id/ll_header" 
     android:layout_above="@+id/ll_footer" 
     android:id="@+id/navigation" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     app:menu="@menu/my_navigation_items" > 


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

    <LinearLayout 
     android:id="@+id/ll_footer" 
     android:background="@android:color/darker_gray" 
     android:layout_alignParentBottom="true" 
     android:layout_height="wrap_content" 
     android:layout_width="match_parent" 
     android:orientation="vertical"> 

     <TextView 
      android:gravity="center" 
      android:id="@+id/nav_footer_textview" 
      android:layout_height="48dp" 
      android:layout_width="match_parent" 
      android:text="Your Footer Text Here" /> 

    </LinearLayout> 

</RelativeLayout> 

例如目的,我已經使用的TextView。

+0

謝謝你。我已經嘗試做它,但它沒有成功。 –

+0

@ NeranjaGunarathne我編輯了這個片段,請檢查它,它爲我工作。 – Shrikant