>
在 activity_main 的 Design 模式下 , 拖动一个 include 容器到布局中 , include 在 Containers 类别下 ;
拖入后 , 选择之前创建的子布局 ;..., 使用 Alt + 回车 快捷键 ,
弹出如下对话框 , 选择 " Convert to data binding layout " 选项 ,
转换为 DataBinding 布局后 , 设置如下数据模型...app:layout_constraintVertical_bias="0.2"
tools:text="18" />
widget.ConstraintLayout...app:layout_constraintTop_toBottomOf="@+id/textView2" />
最后 , 在 二级页面 布局中 , 使用数据模型 ;
<TextView...app:student="@{student}" 配置导入数据模型 ,
即可在子布局中使用该 数据模型 ;
子布局代码 :
<?