禁用某些布局的数据绑定

M'h*_*med 3 android android-gradle-plugin android-databinding

是否可以禁用某些布局的 Android 数据出价?

dataBinding {
    enabled = true // not for all layout, possible ?
}
Run Code Online (Sandbox Code Playgroud)

HAX*_*AXM 7

如果您希望在生成绑定类时忽略布局文件,请将 tools:viewBindingIgnore="true" 属性添加到该布局文件的根视图:

tools:viewBindingIgnore="true"
Run Code Online (Sandbox Code Playgroud)

例如。

<RelativeLayout 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"
tools:viewBindingIgnore="true"
tools:context=".ui.MainActivity">
Run Code Online (Sandbox Code Playgroud)


Iho*_*mov 5

好吧,如果您不使用布局标记包装布局,则不会使用它