如何使抽屉导航页面可滚动?
How to make Drawer Navigation page Scrollable?
嗨,我是编码新手,请原谅我的无知。
制作了一个带抽屉的功能齐全的滑动视图,但我希望抽屉内的导航视图能够向下滚动以查看屏幕外的项目。我尝试将整个内容包装在 ScrollView 中,但是当抽屉布局一直设置为 "match parent" 时我得到 "DrawerLayout must be measured with MeasureSpec.EXACTLY",无法解决它,我不知道这是否在正确的轨道上,请指教,万分感谢!
swipelayout.xml
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".i_SwipingLayout">
<android.support.design.widget.NavigationView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="@layout/i_header"
app:menu="@menu/draw_menu"
app:itemIconTint="@color/ColorDropiii"
app:itemTextColor="@color/ColorDropi">
</android.support.design.widget.NavigationView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/ColorDropi"
android:theme="@style/ToolBarStyle"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light">
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout
android:id="@+id/tablayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/ColorDropi"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
</android.support.design.widget.TabLayout>
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="fill_parent">
</android.support.v4.view.ViewPager>
</LinearLayout>
我找到了答案,不需要使用滚动视图布局来包含所有内容,我只是重新排列对象在抽屉布局中的位置 xml file(page which contains the drawer" 这样nevigationView 低于一切。之后完美运行。
嗨,我是编码新手,请原谅我的无知。
制作了一个带抽屉的功能齐全的滑动视图,但我希望抽屉内的导航视图能够向下滚动以查看屏幕外的项目。我尝试将整个内容包装在 ScrollView 中,但是当抽屉布局一直设置为 "match parent" 时我得到 "DrawerLayout must be measured with MeasureSpec.EXACTLY",无法解决它,我不知道这是否在正确的轨道上,请指教,万分感谢!
swipelayout.xml
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".i_SwipingLayout">
<android.support.design.widget.NavigationView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="@layout/i_header"
app:menu="@menu/draw_menu"
app:itemIconTint="@color/ColorDropiii"
app:itemTextColor="@color/ColorDropi">
</android.support.design.widget.NavigationView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/ColorDropi"
android:theme="@style/ToolBarStyle"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light">
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout
android:id="@+id/tablayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/ColorDropi"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
</android.support.design.widget.TabLayout>
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="fill_parent">
</android.support.v4.view.ViewPager>
</LinearLayout>
我找到了答案,不需要使用滚动视图布局来包含所有内容,我只是重新排列对象在抽屉布局中的位置 xml file(page which contains the drawer" 这样nevigationView 低于一切。之后完美运行。