From daa41bb4f4a5ff19c9e2a17f6744f6ad72f9c5e4 Mon Sep 17 00:00:00 2001 From: Daniel Yu Date: Tue, 8 Dec 2015 10:58:07 -0800 Subject: [PATCH] docs: Adding info on Android Studio support for data binding Adding basic info on Studio's support for data binding. In 1.x this is limited to syntax highlighting, expression error flags, and Preview support for defaults. Added link to tools attributes page. Updated with recommendations from reviewers. Bug: 25974303 Change-Id: I18d86208fd372e041b1dc0697e44e259fa1c9127 --- docs/html/tools/data-binding/guide.jd | 35 +++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/docs/html/tools/data-binding/guide.jd b/docs/html/tools/data-binding/guide.jd index 9629bb022201d..6acc38c2f1445 100644 --- a/docs/html/tools/data-binding/guide.jd +++ b/docs/html/tools/data-binding/guide.jd @@ -131,6 +131,11 @@ page.tags="databinding", "layouts" + +
  • + Android Studio Support for Data Binding +
  • + @@ -211,8 +216,9 @@ android { must configure data binding in its build.gradle file as well.

    Also, make sure you are using a compatible version of Android Studio. -Android Studio 1.3 adds the code-completion and layout-preview -support for data binding.

    +Android Studio 1.3 and later provides support for data binding as described in +Android Studio Support for Data Binding. +

    Data Binding Layout Files @@ -1643,3 +1649,28 @@ public static ColorDrawable convertColorToDrawable(int color) { android:layout_width="wrap_content" android:layout_height="wrap_content"/> + +

    Android Studio Support for Data Binding

    + +

    +Android Studio supports syntax highlighting of data binding expressions, and flags any expression +language syntax errors in the editor. +

    +

    +The Preview pane displays default values for data binding expressions if provided. In the following +example excerpt of an element from a layout XML file, the Preview pane displays the +{@code PLACEHOLDER} default text value in the TextView. +

    + +
    +<TextView android:layout_width="wrap_content"
    +   android:layout_height="wrap_content"
    +   android:text="@{user.firstName, default=PLACEHOLDER}"/>
    +
    + +

    +If you need to display a default value during the design phase of your project, you +can also use tools attributes instead of default expression values, as described in + +Designtime Layout Attributes. +

    \ No newline at end of file