Android MotionLayout приводит к зависанию приложения при изменении масштабирования и масштабирования на некоторых устройствах - PullRequest
1 голос
/ 20 июня 2020

Я использую макет движения в своем проекте, и вот окончательный результат

final result

it looks OK, but Animation plays with lag in some devices

  • Animation plays with lag in old devices (Samsung j5 2016 & Samsung j5 2017 & HTC desire 820)
    here is an old device record : видеофайл
  • Анимация отлично работает в эмуляторе и новых устройствах (Huawei p30 light и Samsung note 8)

в layout description, scaleX и scaleY и alpha меняются

вот мое описание макета исходный код

<?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:constraintSetStart="@+id/start"
        motion:constraintSetEnd="@+id/end"
        motion:duration="1000"/>

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

        <Constraint
            android:id="@id/mock_view"
            android:layout_width="0dp"
            android:layout_height="0dp"
            motion:layout_constraintEnd_toEndOf="parent"
            motion:layout_constraintTop_toTopOf="parent"
            motion:layout_constraintBottom_toBottomOf="parent"/>

        <Constraint
            android:id="@id/cv_content"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:rotation="0"
            android:alpha="1"
            motion:layout_constraintRight_toLeftOf="@+id/button"
            motion:layout_constraintTop_toTopOf="parent"
            motion:layout_constraintWidth_default="percent"/>

        <Constraint
            android:id="@id/content"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:rotation="0"
            motion:layout_constraintRight_toLeftOf="@+id/button"
            motion:layout_constraintTop_toTopOf="parent"
            motion:layout_constraintWidth_default="percent"/>


        <Constraint
            android:id="@id/v_activity_main_content"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            motion:layout_constraintEnd_toEndOf="parent"
            motion:layout_constraintTop_toTopOf="parent"
            motion:layout_constraintBottom_toBottomOf="parent"
            motion:layout_constraintStart_toEndOf="parent"/>

        <Constraint
            android:id="@id/cv_content_shadow"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:alpha="0"
            motion:layout_constraintRight_toRightOf="@+id/content_space"
            motion:layout_constraintTop_toTopOf="parent"
            motion:layout_constraintWidth_default="percent"
            motion:layout_constraintWidth_percent="1" />

        <Constraint
            android:id="@id/content_shadow"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:alpha="0"
            motion:layout_constraintRight_toRightOf="@+id/content_space"
            motion:layout_constraintTop_toTopOf="parent"
            motion:layout_constraintWidth_default="percent"
            motion:layout_constraintWidth_percent="1" />

    </ConstraintSet>

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

        <Constraint
            android:id="@id/mock_view"
            motion:layout_constraintWidth_default="percent"
            motion:layout_constraintWidth_percent="0.6"
            android:layout_height="0dp"
            motion:layout_constraintEnd_toEndOf="parent"
            motion:layout_constraintTop_toTopOf="parent"
            motion:layout_constraintBottom_toBottomOf="parent"/>

        <Constraint
            android:id="@id/cv_content"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:rotation="0"
            android:scaleX="0.72"
            android:scaleY="0.75"
            android:alpha="1"
            motion:layout_constraintRight_toLeftOf="@+id/button"
            motion:layout_constraintTop_toTopOf="parent"
            motion:layout_constraintWidth_default="percent"
            motion:layout_constraintWidth_percent="1" />

        <Constraint
            android:id="@id/content"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:rotation="0"
            android:scaleX="0.72"
            android:scaleY="0.72"
            motion:layout_constraintRight_toLeftOf="@+id/button"
            motion:layout_constraintTop_toTopOf="parent"
            motion:layout_constraintWidth_default="percent"
            motion:layout_constraintWidth_percent="1" />

        <Constraint
            android:id="@id/cv_content_shadow"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:scaleX="0.62"
            android:scaleY="0.65"
            android:alpha="0.3"
            motion:layout_constraintRight_toRightOf="@+id/content_space"
            motion:layout_constraintTop_toTopOf="parent"
            motion:layout_constraintWidth_default="percent"
            motion:layout_constraintWidth_percent="1" />

        <Constraint
            android:id="@id/content_shadow"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:scaleX="0.62"
            android:scaleY="0.62"
            android:alpha="0.3"
            motion:layout_constraintRight_toRightOf="@+id/content_space"
            motion:layout_constraintTop_toTopOf="parent"
            motion:layout_constraintWidth_default="percent"
            motion:layout_constraintWidth_percent="1" />

        <Constraint
            android:id="@id/v_activity_main_content"
            android:layout_width="0dp"
            android:scaleX="0.75"
            android:scaleY="0.75"
            android:layout_height="match_parent"
            motion:layout_constraintRight_toLeftOf="@+id/button"
            motion:layout_constraintTop_toTopOf="parent"
            motion:layout_constraintWidth_default="percent"
            motion:layout_constraintWidth_percent="1"/>

    </ConstraintSet>

</MotionScene>

Есть Любая помощь сделать анимацию без лагов, пожалуйста? и снова здесь видеофайл , который задерживается при запуске анимации

...