Android MotionLayout忽略关键帧集
我正在尝试为动画的第一部分旋转顶卡,为第二部分旋转底卡。持有底牌直到我使用KeyFragmentSet。当我点击topCard MotionLayout时,会忽略KeyFragmentSet,并在整个动画时间内同时旋转两张卡 尝试用setOnClickListener替换XMLOnClick,但同样的情况也发生了 运动场景:Android MotionLayout忽略关键帧集,android,xml,android-motionlayout,Android,Xml,Android Motionlayout,我正在尝试为动画的第一部分旋转顶卡,为第二部分旋转底卡。持有底牌直到我使用KeyFragmentSet。当我点击topCard MotionLayout时,会忽略KeyFragmentSet,并在整个动画时间内同时旋转两张卡 尝试用setOnClickListener替换XMLOnClick,但同样的情况也发生了 运动场景: <MotionScene xmlns:android="http://schemas.android.com/apk/res/android" xml
<MotionScene
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<Transition android:id="@+id/flip_transition"
app:constraintSetEnd="@+id/bottom"
app:constraintSetStart="@+id/top"
app:duration="1500">
<OnClick app:targetId="@id/CL_top_card"
app:clickAction="transitionToEnd"/>
<KeyFrameSet android:id="@+id/flip_keyFrameSet">
<KeyAttribute
app:targetId="@+id/CL_top_card"
app:framePosition="50"
android:rotationY="90"/>
<KeyAttribute
app:targetId="@+id/CL_bottom_card"
app:framePosition="50"
android:rotationY="-90"/>
</KeyFrameSet>
</Transition>
<ConstraintSet android:id="@+id/top">
<Constraint
android:id="@id/CL_top_card"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="40dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:rotationY="0"/>
<Constraint
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="40dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:id="@id/CL_bottom_card"
android:rotationY="-90"/>
</ConstraintSet>
<ConstraintSet
android:id="@+id/bottom">
<Constraint
android:id="@id/CL_top_card"
android:rotationY="90"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="40dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<Constraint
android:id="@id/CL_bottom_card"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="40dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:rotationY="0"/>
</ConstraintSet>
</MotionScene>
xml布局:
<LinearLayout
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="wrap_content"
android:orientation="vertical">
<android.support.constraint.motion.MotionLayout
android:id="@+id/ML_trust_card"
android:layout_width="match_parent"
android:layout_height="350dp"
app:layoutDescription="@xml/scene_flip">
<android.support.constraint.ConstraintLayout
android:id="@+id/CL_top_card"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:rotationY="0">
<TextView
android:id="@+id/tx_task_question"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="40dp"
android:gravity="center"
android:text="TOPtopTOPtopTop00000000000000000000000"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
<android.support.constraint.ConstraintLayout
android:id="@+id/CL_bottom_card"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:rotationY="-90">
<TextView
android:id="@+id/tx_task_answer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="40dp"
android:gravity="center"
android:text="bottombottombottombottom"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
</android.support.constraint.ConstraintLayout>
</android.support.constraint.motion.MotionLayout>
我使用:
实现'com.android.support.constraint:constraint布局:2.0.0-beta2'
我希望顶部卡片先从0旋转到90,底部卡片最后从-90旋转到0。只需在KeyAttributes中将app:targetId替换为app:motionTarget即可。确定。只需在KeyAttributes中将app:targetId替换为app:motionTarget