我正在尝试使用安卓的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'
但是它们似乎都没有用...
以下是我的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 >'
但是它总是给我显示这个错误消息:
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.
在项目的预览窗口中,它会用灰色填充整个布局,并在中心写入以下内容:
android...MotionLayout