【发布时间】:2017-06-12 13:51:50
【问题描述】:
我试图在我的导航抽屉标题中添加一个listView。我有列表,它填充得很好,唯一的问题是我无法滚动列表。似乎nav drawer 本身正在拦截滚动动作并且不允许我滚动ListView
nav_header_drawer.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:layout_width="match_parent"
android:layout_height="260dp"
android:background="@drawable/side_nav_bar"
android:gravity="bottom"
android:orientation="vertical">
<ListView
android:id="@+id/myList"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>
和抽屉
<?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_drawer"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<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"
app:menu="@menu/activity_drawer_drawer" />
如果您需要更多文件,我可以发布
【问题讨论】:
-
只有当子视图大于容器时,
ListView中有多少项目才会滚动? -
@Yupi 列表是动态生成的
-
你需要添加固定大小的数组..
-
@Javacoder 这违背了我想要做的事情的目的。我想要一个动态列表,它只需要滚动
-
任何有此问题的人都可以在这里找到答案stackoverflow.com/a/14577399/5202215
标签: android listview navigation-drawer