ListView in NavigationView not scrolling / NavigationView Menu Disappearing

左心房为你撑大大i 提交于 2020-01-07 03:59:06

问题


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 includeing 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!