마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

네비게이션 뷰 오류..

0 추천

안녕하세요 ^^ 오류 투성이라 미치겠네요 

 

레이아웃을 더 쉽게 할수 있는것 같아 네비뷰를 쓰려는데 왜 자꾸 에러가 뜨는지 정말 미치겠네요;

 

아래 코드입니다.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:minHeight="?attr/actionBarSize" />


    <android.support.v4.widget.DrawerLayout
        android:id="@+id/drawer_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".MainActivity"
        android:layout_below="@+id/toolbar">


        <WebView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/WebView">

        </WebView>

        <RelativeLayout                                           <-- 이부분
            android:id="@+id/drawer"
            android:layout_width="300dp"
            android:layout_height="match_parent"
            android:layout_gravity="start"
            android:background="#ffffff"
            >
        <include
            android:layout_height="match_parent"
            android:layout_width="match_parent"
            layout="@layout/activity_list"/>
        </RelativeLayout>                                                               <-- 여기까지


    </android.support.v4.widget.DrawerLayout>

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="150dp"
        android:layout_height="150dp"
       android:src="@drawable/ic_launcher"
        app:fabSize="normal"
        android:layout_gravity="right"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true" />

</RelativeLayout>

 

이렇게 실행했을대는 네비게이션 드로어가 잘 작동합니다 

드로어 메뉴 안에 채워넣을 내용을 좀더 쉽게 채워넣을려고 위에 표시한 부분을 

 

<android.support.design.widget.NavigationView
            android:id="@+id/drawer"
            android:layout_width="300dp"
            android:layout_height="match_parent"
            android:layout_gravity="start"
            android:background="#ffffff"
            app:headerLayout="@layout/activity_list"
            app:menu="@menu/menu_main"
            >

        </android.support.design.widget.NavigationView>

 

이렇게만 바꿔줬는데 오류가 나네요;; 대체 뭐가 문제죠?? 구글링하니까 더 저렇게 쓰던데 ㅠㅠ;

 

오류 코드는

 

 at com.example.yg.myapplication.MainActivity.onCreate(MainActivity.java:33) 

--> setContentView(R.layout.activity_main);

입니다;

껄껄앱 (1,910 포인트) 님이 2016년 3월 5일 질문

1개의 답변

0 추천
드로어 레이아웃 안에 들어가야 합니다.

해당 최상위 뷰를 드로어 레이아웃으로 변경하세요
익명사용자 님이 2016년 3월 7일 답변
...