2016-08-02 7 views
1

ブランクアクティビティを使用してプロジェクトを開始しました。新しいプロジェクトを作成せずにナビゲーション引き出しアクティビティに切り替えることは可能ですか?ブランクアクティビティからナビゲーション引き出しアクティビティへの切り替え

+0

はいいいえこちらをご覧くださいhttp://stackoverflow.com/questions/19980945/how-do-i-add-navigation-drawer-to-my-existing-code –

+0

ファイル>新規>アクティビティ>引き出しアクティビティ –

答えて

0

あなたはdrawerlayout内コーディネータのレイアウトを持っているので、同じよう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> 
0

は、既存の活動とそのレイアウトを削除し、右のあなたの既存のアクティビティパッケージをクリックしてください次に新規を選択してアクティビティを選択し、アクティビティを選択します。

関連する問題