简体   繁体   English

数据绑定必须包含布局文件

[英]databinding must include a layout file

I have following very simple layout and wanted to switch to using data binding. 我有非常简单的布局,并希望切换到使用数据绑定。 Now I'm getting following error in my controller_main.xml : 现在我在controller_main.xml遇到以下错误:

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

****/ data binding error ****msg:[44 68 44 68 25] must include a layout file:...\\app\\src\\main\\res\\layout\\controller_main.xml ****\\ data binding error **** **** /数据绑定错误****消息:[44 68 44 68 25]必须包含布局文件:... \\ app \\ src \\ main \\ res \\ layout \\ controller_main.xml **** \\ data绑定错误****

Any ideas? 有任何想法吗? The error says, the resource android:layout id in the include tag is missing (that's my interpretation of the error), but that's not true. 错误说,缺少include标签中的资源android:layout id(这是我对错误的解释),但事实并非如此。 Commenting out the include tag removes the error. 注释掉include标记会删除错误。

Does anyone see the problem? 有谁看到这个问题?

controller_main.xml 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>

view_main_header_fixed.xml view_main_header_fixed.xml

<?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" />

You should use layout instead of android:layout : 你应该使用layout而不是android:layout

<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"/>

I had the exact same error, but for a different reason. 我有完全相同的错误,但出于不同的原因。 I was using <include> opening tag and </include> closing tag instead of <include for opening and /> for closing. 我使用<include>开始标记和</include>结束标记而不是<include for opening和/>来关闭。 It's little strange, but anyway your question helped me find my mistake. 这有点奇怪,但无论如何你的问题帮助我找到了我的错误。 Thanks. 谢谢。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android数据绑定:无法传递数据绑定变量以包含布局 - Android databinding: unable to pass databinding variable to include layout Android数据绑定:包含力量 <layout> 标签? - Android Databinding: include forces <layout> tag? 如何设置数据绑定中包含布局的可见性? - How to set visibility for include layout in databinding? 将数据传递给<include>使用数据绑定布局</include> - Pass data to <include> layout using Databinding 如何通过android中的数据绑定将onTextChanged侦听器添加到包含布局xml - How to add onTextChanged listener to an include layout xml by databinding in android Android数据绑定:如何绑定布局标识符以包含 - Android databinding : how can I bind a layout identifier to include 无法将数据绑定中的视图模型传递给子包含布局 - Can't pass viewmodel in databinding to child include layout Android DataBinding layout_width :您必须提供 layout_width 属性 - Android DataBinding layout_width : You must supply a layout_width attribut 如何使用数据绑定从父布局设置布局默认值和<include>标记以便在预览中看到它?</include> - How to set a layout default value from parent layout using databinding and <include> tag in order to see it in preview? 如何修复 &#39; 您必须在 include 标签中指定布局:<include layout=“@layout/layoutID” /> &#39; - How to fix ' You must specifiy a layout in the include tag: <include layout=“@layout/layoutID” />'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM