drawerlayout必须放在主界面布局后面
google的api是这样写的:
To use a DrawerLayout, position your primary content view as the first child with a width and height of match_parent. Add drawers as
child views after the main content view and set the layout_gravity appropriately. Drawers commonly use match_parent for height with
a fixed width.
布局这么写就OK了
android:id="@+id/contact_drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_width="match_parent"
android:layout_height="match_parent"
layout="@layout/activity_contact_list_center"/>
android:id="@+id/contact_list_side"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start"
layout="@layout/activity_contact_list_side"/>
本文详细介绍了如何在Android中正确配置DrawerLayout,包括将其放置在布局中的位置、设置主要内容和抽屉视图的宽度和高度,以及如何通过`layout_gravity`属性控制侧边栏的显示。遵循Google建议的步骤,确保你的应用界面整洁且响应良好。

1178

被折叠的 条评论
为什么被折叠?



