Android Studio 找不到 MotionLayout 的类

Lid*_*lef 5 android android-layout android-studio android-motionlayout

我正在尝试使用 android MotionLayout,但它找不到合适的类并且无法工作。

我尝试实现以下依赖项:

implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta1'
implementation 'com.android.support.constraint:constraint-layout:2.0.0-beta1'
implementation 'com.android.support.constraint:constraint-layout:2.0.0-alpha2'
implementation 'com.android.support.constraint:constraint-layout:2.0.0-alpha4'
Run Code Online (Sandbox Code Playgroud)

但它们似乎都不起作用......

这是我的 XML 文件:

<android.support.constraint.motion.MotionLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
footstools="http://schemas.android.com/tools"
android:id="@+id/motionLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:showPaths="true"
tools:context=".PlayGameActivity">

<View
    android:id="@+id/button"
    android:layout_width="64dp"
    android:layout_height="64dp"
    android:background="@color/colorAccent"
    android:text="Button" />

</android.support.constraint.motion.MotionLayout >'
Run Code Online (Sandbox Code Playgroud)

但它总是给我这个错误按摩:

Missing classes
The following classes could not be found:
- android.support.constraint.motion.MotionLayout (Fix Build Path, Edit XML, Create Class)
Tip: Try to build the project.   
Tip: Try to refresh the layout.
Run Code Online (Sandbox Code Playgroud)

在项目的预览窗口中,它以灰色填充整个布局并在中心写入:

android...MotionLayout
Run Code Online (Sandbox Code Playgroud)

Mar*_*ler 4

没有android.support.constraint.motion.MotionLayout

implementation "androidx.constraintlayout:constraintlayout:2.0.0-beta2"

它被称为androidx.constraintlayout.motion.widget.MotionLayout.

如果MotionLayout显示为灰色,则可能缺少app:layoutDescriptionXML。

有一个AndroidX 和支持库版本的示例。