Android 从空白活动切换到导航抽屉活动
我已使用空白活动启动了一个项目。是否可以在不创建新项目的情况下切换到导航抽屉活动?您可以将内容包装在协调器视图中,然后将协调器布局放在抽屉布局中,并添加导航视图,如下所示:Android 从空白活动切换到导航抽屉活动,android,android-studio,android-activity,Android,Android Studio,Android Activity,我已使用空白活动启动了一个项目。是否可以在不创建新项目的情况下切换到导航抽屉活动?您可以将内容包装在协调器视图中,然后将协调器布局放在抽屉布局中,并添加导航视图,如下所示: <android.support.v4.widget.DrawerLayout android:layout_height="match_parent" android:layout_width="match_parent" xmlns:android="http://schemas.android.com/apk/r
<android.support.v4.widget.DrawerLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
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:foregroundGravity="top"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<android.support.design.widget.CoordinatorLayout
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:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="YOUR_LAYOUT_HERE"/>
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.NavigationView
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/navigation_drawer_header"
app:menu="@menu/navigation_drawer_content"/>
</android.support.v4.widget.DrawerLayout>
您可以将内容包装在CoOrdinator视图中,然后将CoOrdinator布局放在抽屉布局中,并添加NavigationView,如下所示:
<android.support.v4.widget.DrawerLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
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:foregroundGravity="top"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<android.support.design.widget.CoordinatorLayout
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:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="YOUR_LAYOUT_HERE"/>
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.NavigationView
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/navigation_drawer_header"
app:menu="@menu/navigation_drawer_content"/>
</android.support.v4.widget.DrawerLayout>
删除现有活动及其布局,然后右键单击现有活动包,然后选择新建活动,然后选择您的活动。删除现有活动及其布局,然后右键单击现有活动包,然后选择新建活动,然后选择您的活动。是,为什么不查看此处文件>新建>活动>抽屉活动是的,为什么不查看此处文件>新建>活动>抽屉活动