2017-09-19 5 views
-1

Hello evreyone,레이아웃의 다중 루트 오류 -이를 고치는 방법?

레이아웃 XML : Multiple root error에서이 오류가 표시됩니다. 그래서 내가 어떤 해결책을 찾을 수 없습니다 아직 그것을 해결하기 위해 많은 노력 그것에 대해 저를 도와주세요 : enter image description here

덕분에 많이 :)

+1

레이아웃 코드를 이미지가 아닌 텍스트로 추가하십시오. –

답변

0

당신에게이 파일 레이아웃 XML에서 내 코드

입니다 XML에는 부모가없는 요소가 하나만있을 수 있습니다. 귀하 께서 우리에게 주신 희소 한 정보로, 최소한 두 개의 루트 요소 인 <RelativeLayout><android.support.v4.widget.DrawerLayout >이 있습니다.

이 오류를 해결하려면 DrawerLayout 다음에 문서의 끝 부분으로 </RelativeLayout> (닫는 태그)을 이동하기 만하면됩니다. 아니면 다른 레이아웃을 포함하여 <android.support.v4.widget.DrawerLayout >을 처음으로 이동하십시오.

그러나 오류를 수정하더라도이 방법이 좋지 않습니다. DrawerLayout에 대해 더 자세히 읽어야합니다.

0

당신이 레이아웃에 여러 루트 오류가 발생하는 이유로 인해 은 안드로이드의 모든 xml 파일은

그래서 레이아웃

샘플 코드에 하나의 부모를 추가하려고 하나의 루트 레이아웃이 있어야

<?xml version="1.0" encoding="utf-8"?> 

<LinearLayout 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:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

     <!-- add here your other controlls or layouts--> 


    <android.support.v4.widget.DrawerLayout 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:id="@+id/drawer_layout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:fitsSystemWindows="true" 
     tools:openDrawer="start"> 

     <include 
      layout="@layout/app_bar_home_class" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" /> 

     <android.support.design.widget.NavigationView 
      android:id="@+id/nav_view_home" 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:layout_gravity="start" 
      android:fitsSystemWindows="true" 
      app:headerLayout="@layout/nav_header_home_class" 
      app:itemBackground="@android:color/transparent" 
      app:itemIconTint="@color/drawer_item" 
      app:itemTextColor="@color/drawer_item" 
      app:menu="@menu/activity_home_drawer" /> 

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


</LinearLayout>