未找到 MotionLayout class 或未找到属性 layoutDescription
MotionLayout class not found or attribute layoutDescription not found
我正在尝试遵循 MotionLayout 的 google 教程,但似乎无法构建项目,甚至无法找到 class。
这是xml
<androidx.constraintlayout.motion.widget.MotionLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutDescription="@xml/step1_completed">
<ImageView
android:id="@+id/red_star"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/ic_star_outline"
android:tint="?colorSecondary"
android:contentDescription="@string/star"
android:layout_marginTop="30dp"
android:layout_marginStart="30dp"
android:layout_marginBottom="30dp"
android:layout_marginEnd="30dp"/>
</androidx.constraintlayout.motion.widget.MotionLayout>
这里是依赖项
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.1.0'
implementation 'com.android.support.constraint:constraint-layout:2.0.0-beta3'
api 'com.google.android.material:material:1.2.0-alpha03'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
这是我尝试 运行
时得到的结果
AAPT: error: attribute layoutDescription (aka com.google.samples.motionlayoutcodelab:layoutDescription) not found.
谢谢
使用依赖的AndroidX版本:
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta4'
我正在尝试遵循 MotionLayout 的 google 教程,但似乎无法构建项目,甚至无法找到 class。
这是xml
<androidx.constraintlayout.motion.widget.MotionLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutDescription="@xml/step1_completed">
<ImageView
android:id="@+id/red_star"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/ic_star_outline"
android:tint="?colorSecondary"
android:contentDescription="@string/star"
android:layout_marginTop="30dp"
android:layout_marginStart="30dp"
android:layout_marginBottom="30dp"
android:layout_marginEnd="30dp"/>
</androidx.constraintlayout.motion.widget.MotionLayout>
这里是依赖项
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.1.0'
implementation 'com.android.support.constraint:constraint-layout:2.0.0-beta3'
api 'com.google.android.material:material:1.2.0-alpha03'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
这是我尝试 运行
时得到的结果AAPT: error: attribute layoutDescription (aka com.google.samples.motionlayoutcodelab:layoutDescription) not found.
谢谢
使用依赖的AndroidX版本:
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta4'