android / views-widgets-samples

Multiple samples showing the best practices in views-widgets on Android.
Apache License 2.0
5.03k stars 3.01k forks source link

Question: How to use Motionlayout with databinding #187

Closed Berki2021 closed 3 years ago

Berki2021 commented 3 years ago

My question is, how can we use Motion layout in combination with Databinding? I tried to wrap my Motion layout with <layout> </layout> but then, the Motion editor disappeared. Does this mean, that Motion layout is not compatible with Databinding?

Example (not working):

<?xml version="1.0" encoding="utf-8"?>

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

    <data>
        <variable
            name="product"
            type="com.example.app.framework.datasource.models.product.Product" />
    </data>

    <androidx.constraintlayout.motion.widget.MotionLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layoutDescription="@xml/shop_item_content_scene">

    </androidx.constraintlayout.motion.widget.MotionLayout>
</layout>