1

I have started a project using blank activity.Is it possible to switch to navigation drawer activity without having to create a new project?

2 Answers2

0

You can wrap up your content inside a CoOrdinator view then have the coordinator layout inside a drawerlayout and add the NavigationView like so:

<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>
Noel Omondi
  • 551
  • 1
  • 6
  • 23
0

delete the existing activity and its layout and right click your existing activity package then select new and then activity and select your your activity .

santhosh
  • 31
  • 7