Android 使用LinearLayout而不是RecyclerView in DrumerLayout
由于导航抽屉使用的是固定菜单,因此我尝试在抽屉布局的第二个子项中使用LinearLayout,而不是RecyclerView/ListView,以便于编码。但结果是全屏幕线性布局。有没有办法在抽屉布局中使用常规视图(如linearlayout)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
<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是什么样子的?里面没有视图吗?你唯一应该记住的是:第一个孩子是你的主要内容,第二个孩子是你的抽屉内容(据我所知,可以是任何视图组)。