当前状态:具有 NavigationHeader 和 NavigationMenu 项的 NavigationDrawer。这些项目数量很大,因此需要滚动才能访问底部的项目。
要求:向下滚动到底部时,导航标题应保持固定
这是我的 Activity_main 布局文件
<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_main"
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"
android:background="#00000000"
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer"
/>
</android.support.v4.widget.DrawerLayout>
这是我的 navigation_header_main 布局文件
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="100dp"
android:orientation="vertical"
android:background="#3d3b3b"
android:theme="@style/ThemeOverlay.AppCompat.Dark">
<android.support.v7.widget.AppCompatImageView
android:layout_width="match_parent"
android:layout_height="100dp"
android:src="@drawable/categories"
android:padding="1dp"
/>
</RelativeLayout>
P.S 我是 Android 开发新手。如果需要,请索取更多资源
找到了解决方法。绝对不是最有效率的。请建议是否可以从这里做任何事情。
<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_main"
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"
android:background="#00000000"
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer">
<include layout="@layout/nav_header_main"
<android.support.design.widget.NavigationView>
绝对有效。但标题布局是多余的
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)