Hadi
Hadi

Reputation: 124

Motion Layout freeze during play animation

I have made a simple animation to show when an activity starts. this is my animation:

enter image description here

The problem is on emulator sometimes animation plays correctly but sometimes freeze and I have to reopen the app. and on my phone it always freeze.

What I have done is I have made 2 separate layout one for "start" and the other for "end" scene and in start layout I increased left margin of my moving views. following code belong to my moving image.

one of moving views in start XML file:

.
.
 <com.google.android.material.imageview.ShapeableImageView
        android:id="@+id/metal_iv"
        android:layout_width="300dp"
        android:layout_height="match_parent"

        android:layout_marginStart="400dp"

        android:layout_marginBottom="@dimen/backgroundMarginRegisterActivity"
        android:background="@drawable/background_gray"
        android:elevation="-1dp"
        android:scaleType="fitXY"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:shapeAppearanceOverlay="@style/OnlyOneCorner"/>
.
.

in XML end layout I have reduced left margin:

android:layout_marginStart="40dp"

and this is my scene.xml file:

<MotionScene 
    xmlns:motion="http://schemas.android.com/apk/res-auto">

    <Transition
        motion:constraintSetEnd="@layout/activity_end"
        motion:constraintSetStart="@layout/activity_start"
        motion:autoTransition="animateToEnd"
        motion:duration="1000">
    </Transition>
</MotionScene>

I don`t know that is related or not, but the start and end scene does not show in design view window.

enter image description here

Upvotes: 1

Views: 1005

Answers (1)

Hadi
Hadi

Reputation: 124

Finally I solved the problem . actually at this time the latest version of constraint dependency is beta8. But downgrading to this version solved my problem:

implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta3'

Upvotes: 1

Related Questions