Android 抽屉布局中的滚动
我一直在尝试在Android中实现导航抽屉。它包含一个imageView布局、两个ListView和一些其他视图。但是,在较小的屏幕中,我应该添加一个scollView,以便可以滚动和查看整个抽屉 布局文件为:Android 抽屉布局中的滚动,android,listview,navigation-drawer,android-scrollview,Android,Listview,Navigation Drawer,Android Scrollview,我一直在尝试在Android中实现导航抽屉。它包含一个imageView布局、两个ListView和一些其他视图。但是,在较小的屏幕中,我应该添加一个scollView,以便可以滚动和查看整个抽屉 布局文件为: <?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/andro
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<!-- The main content view -->
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<!-- The navigation drawer -->
<LinearLayout
android:id="@+id/drawer_LinearLayout_left"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@color/orange_transparent"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/yellow"
android:orientation="horizontal"
android:paddingBottom="24dp" >
<com.app.RoundImageView
android:id="@+id/pic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp" />
<LinearLayout
android:id="@+id/name_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="View Account"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<ImageView
android:id="@+id/imageNext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_action_next_item" />
</LinearLayout>
<Button
android:id="@+id/locationButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:text="Choose location" />
<ListView
android:id="@+id/left_drawer_top"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
android:listSelector="@drawable/selector1" />
<TextView
android:id="@+id/section_more"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="MORE"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textStyle="bold" />
<View
android:id="@+id/separator"
android:layout_width="match_parent"
android:layout_height="3dp"
android:layout_marginBottom="3dp"
android:layout_marginTop="3dp"
android:background="#DADADC" />
<ListView
android:id="@+id/left_drawer_bottom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
android:listSelector="@drawable/selector1" />
</LinearLayout>
</android.support.v4.widget.DrawerLayout>
但是,在添加滚动视图之后,每个listview都被限制为一个具有滚动功能的元素列表
添加scrollView后抽屉的布局文件为:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<!-- The main content view -->
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<!-- The navigation drawer -->
<ScrollView
android:id="@+id/scrollView_Leftdrawer"
android:layout_width="240dp"
android:layout_height="wrap_content"
android:layout_gravity="start" >
<LinearLayout
android:id="@+id/drawer_LinearLayout_left"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/orange_transparent"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/yellow"
android:orientation="horizontal"
android:paddingBottom="24dp" >
<com.app.RoundImageView
android:id="@+id/pic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp" />
<LinearLayout
android:id="@+id/name_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="View Account"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<ImageView
android:id="@+id/imageNext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_action_next_item" />
</LinearLayout>
<Button
android:id="@+id/locationButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:text="Choose location" />
<ListView
android:id="@+id/left_drawer_top"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
android:listSelector="@drawable/selector1" />
<TextView
android:id="@+id/section_more"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="MORE"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textStyle="bold" />
<View
android:id="@+id/separator"
android:layout_width="match_parent"
android:layout_height="3dp"
android:layout_marginBottom="3dp"
android:layout_marginTop="3dp"
android:background="#DADADC" />
<ListView
android:id="@+id/left_drawer_bottom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
android:listSelector="@drawable/selector1" />
</LinearLayout>
</ScrollView>
</android.support.v4.widget.DrawerLayout>
请帮助我如何将滚动视图添加到满抽屉。如果将滚动视图作为xml中的第一个视图,它是否有效?在FrameLayout之前,不能在scrollview中使用listview。那么应用程序如何知道滚动哪个视图呢。我不知道listview中会有多少个项目,但是如果没有那么多,就创建视图吧,因为你已经有了一个scrollview。谢谢,我得到了这个。相反,我构建了一个自定义视图。