Motionlayout с переработчиком View является шатким - PullRequest
0 голосов
/ 30 декабря 2018

Я использовал вид рециркулятора в своем макете движения с ручкой, которая является ImageView. Но в первый раз, когда вы хотите провести его пальцем вверх, он трясется, опускается и поднимается, а не поднимается.

Я попытался поиграть с атрибутами, но ничего не получилось.

макет:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
    tools:context=".MainActivity"
    android:id="@+id/root">

    <androidx.constraintlayout.motion.widget.MotionLayout
        android:id="@+id/motionLayout"
        app:layoutDescription="@xml/scene3"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:showPaths="true">
        <ImageView
            android:id="@+id/image"
            android:src="@drawable/ic_launcher_background"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:layout_constraintBottom_toTopOf="@id/testId" />

        <RelativeLayout
            android:id="@+id/testId"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintTop_toBottomOf="parent"
            app:layout_constraintVertical_chainStyle="spread">

            <androidx.recyclerview.widget.RecyclerView
                android:id="@+id/recycler_media_view"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginTop="10dp"/>

            <com.google.android.material.floatingactionbutton.FloatingActionButton
                android:id="@+id/media_send_fab"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentEnd="true"
                android:layout_alignParentBottom="true"
                android:layout_margin="16dp"
                android:onClick="sendTheMessages"
                app:fabSize="normal" />
        </RelativeLayout>
    </androidx.constraintlayout.motion.widget.MotionLayout>
</RelativeLayout>

scene3.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="300"
        motion:interpolator="linear">
        <OnSwipe
            motion:touchAnchorId="@+id/image"
            motion:touchAnchorSide="bottom"
            motion:dragDirection="dragUp"
            motion:dragScale="5"
            motion:maxVelocity="5000"
            motion:moveWhenScrollAtTop="true" />
    </Transition>
    <ConstraintSet android:id="@+id/start">
        <Constraint
            android:id="@+id/testId"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            motion:layout_constraintBottom_toBottomOf="parent"
            motion:layout_constraintTop_toBottomOf="parent"
            motion:layout_constraintVertical_chainStyle="spread">
        </Constraint>
    </ConstraintSet>
    <ConstraintSet android:id="@+id/end">
        <Constraint
            android:id="@+id/testId"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            motion:layout_constraintBottom_toBottomOf="parent"
            motion:layout_constraintTop_toTopOf="parent"
            motion:layout_constraintVertical_chainStyle="spread">
        </Constraint>
    </ConstraintSet>
</MotionScene>

Используя следующие файлы, вы можете восстановитьПроблема. Спасибо за чтение. Любая помощь будет оценена.

...