问题
I have a Nav Drawer where the header has a ListView
, and the body is a standard menu
. I have two implementations of this, each one with its own problem
The drawer should look like this: (white square is the ListView)
The 1st implementation shows both views but doesn't allow scrolling of the ListView in the header. Any scrolling is "intercepted" by the nav Drawer
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_drawer" //contains my listView
app:menu="@menu/activity_drawer_main" >
</android.support.design.widget.NavigationView>
In the 2nd implementation, I fixed the scrolling issue by include
ing the header separately in the navView. It scrolls, but now the menu list is gone. It doesn't show at all.
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:menu="@menu/activity_drawer_main" >
<include
layout="@layout/nav_header_drawer"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.design.widget.NavigationView>
The drawer should look like the image above, but implementation 1 (pictured) won't scroll, and implementation two doesn't have the menu items (share, send).
Any help figuring out how to fix either implementation is appreciated!
Note: I know I could create a LinearLayout of items in place of the menu, but it doesn't look as nice, with the graying out when tapped. I could code that as well, but I feel like the functionality is built in, (I just can't access it), so why build it from scratch?
回答1:
I found out how to override the navigation view's intercepting the listview's scroll here https://stackoverflow.com/a/14577399/5202215
来源:https://stackoverflow.com/questions/44689907/listview-in-navigationview-not-scrolling-navigationview-menu-disappearing