NavigationView中的ListView不滚动/NavigationView菜单消失 [英] ListView in NavigationView not scrolling / NavigationView Menu Disappearing

查看:178
本文介绍了NavigationView中的ListView不滚动/NavigationView菜单消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个导航抽屉,其中标题有一个ListView,主体是标准的menu.我有两个实现,每个实现都有自己的问题

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

抽屉应该看起来像这样:(白色正方形是ListView)

The drawer should look like this: (white square is the ListView)

第一个实现显示两个视图,但不允许滚动标题中的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>

在第二个实现中,我通过include在navView中单独设置标题解决了滚动问题.它会滚动,但是现在菜单列表不见了.它根本不显示.

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>

抽屉应类似于上图,但是实现1(如图所示)不会滚动,实现2没有菜单项(共享,发送).

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!

注意:我知道我可以创建菜单项的LinearLayout,但是它看起来不太好,点击时会变灰.我也可以编写代码,但是我感觉该功能是内置的(我无法访问它),那么为什么要从头开始构建它?

推荐答案

我在这里找到了如何覆盖导航视图和列表视图滚动的 https://stackoverflow.com/a/14577399/5202215

I found out how to override the navigation view's intercepting the listview's scroll here https://stackoverflow.com/a/14577399/5202215

这篇关于NavigationView中的ListView不滚动/NavigationView菜单消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆