Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/208.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 使用LinearLayout而不是RecyclerView in DrumerLayout_Android_Android Layout_Android Linearlayout_Android Recyclerview_Navigation Drawer - Fatal编程技术网

Android 使用LinearLayout而不是RecyclerView in DrumerLayout

Android 使用LinearLayout而不是RecyclerView in DrumerLayout,android,android-layout,android-linearlayout,android-recyclerview,navigation-drawer,Android,Android Layout,Android Linearlayout,Android Recyclerview,Navigation Drawer,由于导航抽屉使用的是固定菜单,因此我尝试在抽屉布局的第二个子项中使用LinearLayout,而不是RecyclerView/ListView,以便于编码。但结果是全屏幕线性布局。有没有办法在抽屉布局中使用常规视图(如linearlayout) <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas

由于导航抽屉使用的是固定菜单,因此我尝试在抽屉布局的第二个子项中使用LinearLayout,而不是RecyclerView/ListView,以便于编码。但结果是全屏幕线性布局。有没有办法在抽屉布局中使用常规视图(如linearlayout)

<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" />
<LinearLayout
    android:orientation="vertical"
    android:layout_width="wrap_content"
    android:layout_height="match_parent">
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello world"/>
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Bye world"/>
</LinearLayout>


任何
视图
都可以充当
抽屉布局
中的抽屉。要使
抽屉布局
视图
识别为抽屉,必须将
布局
属性设置为
/
开始
/
结束
,具体取决于要将抽屉连接到的垂直边缘

抽屉的
布局高度
通常是
匹配父项
,因此抽屉跨越
抽屉布局的整个高度
,其
布局宽度
通常是一个精确的测量值,例如
240dp
,以保持一致的宽度,不受其内容影响


此外,抽屉
视图
必须在
抽屉布局
中列在最后,以保持正确的z顺序,否则它将被内容
视图
覆盖,并且不会接收单击事件。

是否有任何方法在抽屉布局中使用常规视图(如线性布局)?-是。您必须正确设置
抽屉布局
及其子视图
视图。如何设置抽屉布局以使用LinearLayout而不是RecyclerView?与使用
RecyclerView
的方法相同,替换
LinearLayout
。抽屉布局的XML是什么样子的?里面没有视图吗?你唯一应该记住的是:第一个孩子是你的主要内容,第二个孩子是你的抽屉内容(据我所知,可以是任何视图组)。