我打算使用NavigationView,而不是在DrawerLayout中滚动自己的菜单,但不是使用NavView的菜单结构,而是在NavView标记中使用自己的ListView。IOW,我确实在NavView中有一个app:headerLayout,但是没有app:menu属性。
这工作到抽屉打开和关闭,并显示我的列表,如预期与以下两个小故障:它滑动在我的ActionBar和标题没有显示。标题在布局中,我可以找到它的ID,但没有显示它。
所以我想做的是可能的吗?我尝试使用NavView的唯一真正原因是它正确地处理了抽屉的宽度,但如果不能按我的意愿显示其余的部分,我可以不使用它。
发布于 2015-11-17 17:51:02
也许您可以在listview中使用navigationView
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/main_toolbar" />
</FrameLayout>
<android.support.design.widget.NavigationView
android:id="@+id/navigation_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"/>
<ListView
android:id="@+id/menuList"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</android.support.v4.widget.DrawerLayout>您不能使用app:header和app:menu,因为您正在使用列表视图。您必须手动创建标头。
https://stackoverflow.com/questions/33763424
复制相似问题