【发布时间】:2019-10-18 17:45:39
【问题描述】:
有人可以帮我解决这个问题吗?当我向下滚动时,我不明白为什么我的项目列表在 DrawerLayout 的标题后面。
<?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/activity_MainActivity"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#6b6b6b"
android:fitsSystemWindows="true"
android:theme="@style/NavigationTheme"
app:headerLayout="@layout/format_appdrawerheader"
app:itemBackground="@drawable/nav_view_item_background"
app:itemTextColor="@drawable/nav_view_item_textcolor"
app:menu="@menu/category_menu">
<include layout="@layout/format_appdrawerheader" />
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
感谢您的帮助
编辑:用图片会更容易理解。
所以,当我的应用程序启动时,我的 NavigationView 看起来像这样。较暗的部分是标题,较亮的部分是用菜单制作的列表。 向下滚动时,只有较轻的部分在移动(这正是我想要的),但它在标题下方滑动。因此,如果我单击标题中的空白区域,如第二张图片(红色框架),它会选择后面的项目,在本例中为“项目 1”。
【问题讨论】:
-
有什么问题?当滚动时,项目位于标题后面是正常行为。你还想要什么?
-
问题不在于项目在标题后面的事实,问题在于即使它们不可见,它们仍然可以点击。
标签: android header drawerlayout navigationview