Android Studio 找不到 类 MotionLayout
Android Studio can't find classes for 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'
但其中 none 似乎有效...
这是我的 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.
并且在项目的预览 window 中,它将整个布局填充为灰色并在中心写入:
android...MotionLayout
没有android.support.constraint.motion.MotionLayout
在 implementation "androidx.constraintlayout:constraintlayout:2.0.0-beta2"
.
叫做androidx.constraintlayout.motion.widget.MotionLayout
。
如果 MotionLayout
显示为灰色,您可能缺少 app:layoutDescription
XML。
AndroidX 和支持库版本有 example。
我正在尝试使用 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'
但其中 none 似乎有效...
这是我的 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.
并且在项目的预览 window 中,它将整个布局填充为灰色并在中心写入:
android...MotionLayout
没有android.support.constraint.motion.MotionLayout
在 implementation "androidx.constraintlayout:constraintlayout:2.0.0-beta2"
.
叫做androidx.constraintlayout.motion.widget.MotionLayout
。
如果 MotionLayout
显示为灰色,您可能缺少 app:layoutDescription
XML。
AndroidX 和支持库版本有 example。