Android 设置动画时未调整MotionLayout的大小
我有这样的看法:Android 设置动画时未调整MotionLayout的大小,android,android-layout,android-motionlayout,Android,Android Layout,Android Motionlayout,我有这样的看法: <androidx.constraintlayout.motion.widget.MotionLayout android:id="@+id/expandableModes" android:layout_width="200dp" android:layout_height="200dp"
<androidx.constraintlayout.motion.widget.MotionLayout
android:id="@+id/expandableModes"
android:layout_width="200dp"
android:layout_height="200dp"
android:paddingBottom="5dp"
app:layoutDescription="@xml/journey_motion"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@id/guidelineLeft"
app:layout_constraintTop_toBottomOf="@id/travelModeText">
....
</androidx.constraintlayout.motion.widget.MotionLayout>
我的动画已播放,但我的视图未调整大小,我错过了什么?您正在尝试为运动布局本身设置动画。只能按以下说明设置直接子对象的动画:
您需要创建视图的子视图并设置动画。您正在尝试设置运动布局本身的动画。只能按以下说明设置直接子对象的动画: 您需要创建视图的子视图并设置动画
<?xml version="1.0" encoding="utf-8"?>
<MotionScene xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<Transition
app:constraintSetEnd="@id/endExpand"
app:constraintSetStart="@id/startExpand"
app:duration="1000" />
<ConstraintSet android:id="@+id/startExpand">
<Constraint
android:id="@id/expandableModes"
android:layout_width="200dp"
android:layout_height="200dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@id/guidelineLeft"
app:layout_constraintTop_toBottomOf="@id/travelModeText" />
</ConstraintSet>
<ConstraintSet android:id="@+id/endExpand">
<Constraint
android:id="@id/expandableModes"
android:layout_width="10dp"
android:layout_height="10dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@id/guidelineLeft"
app:layout_constraintTop_toBottomOf="@id/travelModeText" />
</ConstraintSet>
</MotionScene>
binding.expandableModes.transitionToEnd {
print("")
}