Как сделать анимацию шоу только один раз с помощью MotionLayout - PullRequest
0 голосов
/ 07 августа 2020
  1. Переход макета в движении работает при каждом щелчке по поисковому просмотру, вместо того, чтобы после завершения одного перехода следующий щелчок по поисковому просмотру не должен анимироваться в начальную позицию.
  2. Переход работает только со значком просмотра поиска вместо просмотра макет

motion_scene. xml

<?xml version="1.0" encoding="utf-8"?>
<MotionScene 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:motion="http://schemas.android.com/apk/res-auto">

    <Transition
        motion:constraintSetEnd="@+id/end"
        motion:constraintSetStart="@id/start"
        motion:duration="1000">
       <KeyFrameSet>
       </KeyFrameSet>
        <OnClick motion:targetId="@+id/searchView2"
            />
    </Transition>

    <ConstraintSet android:id="@+id/start">
    </ConstraintSet>

    <ConstraintSet android:id="@+id/end">
        <Constraint
            android:layout_height="wrap_content"
            motion:layout_constraintStart_toStartOf="parent"
            motion:layout_constraintTop_toTopOf="parent"
            motion:layout_constraintEnd_toEndOf="parent"
            android:layout_width="0dp"
            android:id="@+id/searchView2" />
    </ConstraintSet>
</MotionScene>

activity_main. 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/activity_main_scene"
    tools:context=".MainActivity">


    <SearchView
        android:id="@+id/searchView2"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:iconifiedByDefault="false"
        android:queryHint="Search"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.motion.widget.MotionLayout>

введите описание изображения здесь

...