MotionLayout игнорирует KeyFrameSet

Я пытаюсь повернуть верхнюю карту для первой части анимации и повернуть нижнюю карту для второй. Чтобы удерживать нижнюю карту, пока не придет время, я использую KeyFragmentSet. Когда я нажимаю на верхнюю карту, MotionLayout игнорирует KeyFragmentSet и просто одновременно поворачивает обе карты в течение всего времени анимации.

Пробовал заменить XML onClick на setOnClickListener, но происходит то же самое.

Сцена движения:

<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>

I use:

реализация 'com.android.support.constraint:constraint-layout:2.0.0-beta2'

Я ожидаю, что сначала topCard будет поворачиваться от 0 до 90, а нижний — от -90 до 0 в последнюю очередь.


person Мой Господин    schedule 18.07.2019    source источник


Ответы (1)


Ok. Просто замените app:targetId на app:motionTarget в KeyAttributes.

person Мой Господин    schedule 18.07.2019