I have started a project using blank activity.Is it possible to switch to navigation drawer activity without having to create a new project?
Asked
Active
Viewed 2,300 times
1
-
yes why not look here http://stackoverflow.com/questions/19980945/how-do-i-add-navigation-drawer-to-my-existing-code – Sohail Zahid Aug 02 '16 at 12:03
-
1File > new > activity > drawer activity – Tim Aug 02 '16 at 12:03
2 Answers
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