Home > Software engineering >  How to adjust the direction of appearance of GONE views for the MotionLayout?
How to adjust the direction of appearance of GONE views for the MotionLayout?

Time:09-17

See source enter image description here

But if update to Version androidx.constraintlayout:constraintlayout:2.1.0:

The view is going from top-left

enter image description here

How to fix it?

CodePudding user response:

The basic problem is ConstraintLayout gone ends up at 0,0 size 0,0.

There are two possible solutions.

  1. have a 3rd ConstraintSet. So go from normal to invisible then go to Gone.
  2. Create KeyFrames of type KeyPosition at framePosition=99 percentX=0, percentY=0

The first fades in the transition to invisible then transitions to Gone. You can AutoTransition to the second gone.

The Second says 0 movement till you hit the last 1% by which time the they are invisible.

  • Related