2016-09-12 1 views
4

다음과 같은 매우 간단한 레이아웃을 가지고 있으며 데이터 바인딩을 사용하여 전환하고 싶습니다. 지금은 내 controller_main.xml에 다음과 같은 오류를 받고 있어요 :데이터 바인딩에는 레이아웃 파일이 포함되어야합니다.

Error:Execution failed for task ':app:dataBindingProcessLayoutsDebug_pro'. 

****/데이터 바인딩 오류 ****의 MSG : 44 68 44 68 25] 레이아웃 파일을 포함해야합니다 .. . \ app \ src \ main \ res \ layout \ controller_main.xml **** \ 데이터 바인딩 오류 ****

아이디어가 있으십니까? 오류 메시지에는 태그의 리소스 이 누락되었습니다 (이것이 내 오류 해석 임).하지만 그렇지 않습니다. include 태그를 주석 처리하면 오류가 제거됩니다.

누구에게이 문제가 표시됩니까?

controller_main.xml

<layout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" > 

    <android.support.design.widget.CoordinatorLayout 
     android:id="@+id/coordinatorLayout" 
     android:fitsSystemWindows="true" 
     android:background="?attr/main_background_color" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" > 

     <RelativeLayout 
      android:id="@+id/rlContent" 
      android:fitsSystemWindows="true" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 

     </RelativeLayout> 

     <include 
      android:layout_width="fill_parent" 
      android:layout_height="@dimen/tool_bar_top_padding" 
      android:id="@+id/stub_view_main_header_fixed" 
      android:layout="@layout/view_main_header_fixed" 
      app:elevation="0dp"/> 

     <android.support.design.widget.AppBarLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"> 

      <android.support.v7.widget.Toolbar 
       android:id="@+id/toolbar" 
       android:layout_width="match_parent" 
       android:layout_height="?attr/actionBarSize" 
       android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" /> 

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

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

</layout> 

당신은 layout 대신 android:layout를 사용해야합니다

<?xml version="1.0" encoding="utf-8"?> 
<View 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/vStatusbarBackground" 
    android:layout_width="match_parent" 
    android:layout_height="@dimen/tool_bar_top_padding" /> 
+0

'포함하여에서 "ID e 태그가 누락되었습니다. ", 이것에 대해 명확하지 않은 점은 무엇입니까? – pskink

+0

포함이 표시됩니까? ID를 정의하고 있습니다. 그리고 include 태그의 id가 어디에서 누락되었는지를 알 수 없습니다. 레이아웃이 없습니다. 그러나 레이아웃도 정의되어 있습니다. 문제는 어쨌든 이미 해결되었습니다 ... – prom85

답변

7

view_main_header_fixed.xml :

<include 
     android:layout_width="fill_parent" 
     android:layout_height="@dimen/tool_bar_top_padding" 
     android:id="@+id/stub_view_main_header_fixed" 
     layout="@layout/view_main_header_fixed" 
     app:elevation="0dp"/> 
+0

이미 발견했습니다 ;-) thanks. 'ViewStubs'를 사용하는 것에서 여러개의 레이아웃을 포함하는 것으로 변화 한 것이 포함되어 있습니다 ... – prom85