Search code examples
androidandroid-layoutandroid-constraintlayoutandroid-transitionsandroid-motionlayout

How to adjust the direction of appearance of GONE views for the MotionLayout?


See source https://github.com/suchoX/DraggableView

Version androidx.constraintlayout:constraintlayout:2.0.0-rc1

Views with attr gone(for ex. button next_image_view ) are going from the bottom. It is correct. See screen shot

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?


Solution

  • 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.