五十、【MVVM DataBinding】

244 阅读1分钟

1.app -> build.gradle 下

    // dataBinding 加入
    dataBinding {
        enabled = true
    }

2.xml中 layout改写

<layout>
 // 其他的布局代码
</layout>

如:

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

    <FrameLayout xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context="com.example.jingbin.cloudreader.ui.gank.child.AndroidFragment">

        <com.example.xrecyclerview.XRecyclerView
            android:id="@+id/xrv_android"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:scrollbarFadeDuration="1"
            android:scrollbarSize="4dp"
            android:scrollbarThumbVertical="@color/tabBackground"
            android:scrollbars="vertical" />

    </FrameLayout>
</layout>