固定了在导航抽屉中滚动项目时的导航标题 [英] Fixed navigation header in navigation drawer while scrolling through items
问题描述
当前状态:带有NavigationHeader和NavigationMenu项目的NavigationDrawer.这些项目数量很大,因此需要滚动才能将这些项目移到底部.
CURRENT STATE: NavigationDrawer with a NavigationHeader and NavigationMenu items. The items are large in number so scrolling is required in order to access the items towards the bottom.
要求:向下滚动到底部时,NavigationHeader应该保持固定状态
REQUIREMENT: When scrolling down to the bottom, the NavigationHeader should stay fixed
这是我的activity_main布局文件
Here's my activity_main layout file
<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布局文件
Here's my navigation_header_main layout file
<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 dev的新手.如果需要,请询问更多资源
P.S I am new to android dev. Please ask for more resources if required
推荐答案
找到了解决方法.绝对不是最有效的一种.请建议是否可以从这里进行任何操作.
Found a workaround. Definitely not the most efficient one. Please suggest if anything could be done from here.
<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>
绝对有效.但是标题布局是多余的
Definitely works. But the header layout is redundant
这篇关于固定了在导航抽屉中滚动项目时的导航标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!