[null,null,["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# App Architecture: UI Layer - Get Started - Android Developers\n\nGet started\n===========\n\nLearn how to get your development environment ready to work with the Data\nBinding Library, including support for data binding code in Android Studio.\n\nThe Data Binding Library offers both flexibility and broad\ncompatibility---it's a support library, so you can use it with devices\nrunning Android 4.0 (API level 14) or higher.\n\nWe recommend using the latest Android Gradle plugin in your project.\nHowever, data binding is supported on version 1.5.0 and higher. For more\ninformation, see how to [update the Android Gradle\nplugin](/studio/releases/gradle-plugin#updating-plugin).\n\nBuild environment\n-----------------\n\nTo get started with data binding, download the library from the **Support\nRepository** in the Android SDK manager. For more information, see [Update the\nIDE and SDK Tools](/studio/intro/update).\n\nTo configure your app to use data binding, enable the `dataBinding` build option\nin your `build.gradle` file in the app module, as shown in the following\nexample: \n\n android {\n ...\n buildFeatures {\n dataBinding true\n }\n }\n\n| **Note:** You must configure data binding for app modules that depend on libraries that use data binding, even if the app module doesn't directly use data binding.\n\nAndroid Studio support for data binding\n---------------------------------------\n\nAndroid Studio supports many of the editing features for data binding code. For\nexample, it supports the following features for data binding expressions:\n\n- Syntax highlighting\n- Flagging of expression language syntax errors\n- XML code completion\n- References, including [navigation](https://www.jetbrains.com/help/idea/2017.1/navigation-in-source-code.html)---such as navigating to a declaration---and [quick documentation](https://www.jetbrains.com/help/idea/2017.1/viewing-inline-documentation.html)\n\n| **Caution:** Arrays and a [generic\n| type](https://docs.oracle.com/javase/tutorial/java/generics/types.html), such as the [`Observable`](/reference/androidx/databinding/Observable) interface, might incorrectly display errors.\n\nThe **Preview** pane in the **Layout Editor** displays the default value of data\nbinding expressions, if provided. For example, the **Preview** pane displays the\n`my_default` value on the `TextView` widget declared in the following example: \n\n \u003cTextView android:layout_width=\"wrap_content\"\n android:layout_height=\"wrap_content\"\n android:text=\"@{user.firstName, default=my_default}\"/\u003e\n\nIf you need to display a default value only during the design phase of your\nproject, you can use `tools` attributes instead of default expression values, as\ndescribed in the [Tools attributes reference](/studio/write/tool-attributes).\n\nAdditional resources\n--------------------\n\nTo learn more about data binding, consult the following\nadditional resources.\n\n- [Android Data Binding Library samples](https://github.com/android/databinding-samples)\n\n\u003c!-- --\u003e\n\n- [Data Binding in Android codelab](https://codelabs.developers.google.com/codelabs/android-databinding)\n\n\u003c!-- --\u003e\n\n- [Data Binding --- lessons learnt](https://medium.com/androiddevelopers/data-binding-lessons-learnt-4fd16576b719)\n\nRecommended for you\n-------------------\n\n- Note: link text is displayed when JavaScript is off\n- [Work with observable data objects](/topic/libraries/data-binding/observability)\n- [View binding](/topic/libraries/view-binding)\n- [Paging 2 library overview](/topic/libraries/architecture/paging)"]]