ConstraintLayout version: 2.0.0-alpha3
So I am using MotionLayout I wanted to create something similar to this. https://blog.stylingandroid.com/motionlayout-collapsi
I've managed to get a work around for this issue until alpha4 is released.
In my use case I have a button which is normally only shown when a list is in end it mode. So to keep it hidden when the list isn't in edit mode I'm changing the constraints based on the edit mode.
private void enableDoneButton(boolean enabled){
int visibility = enabled ? View.VISIBLE : View.GONE;
ConstraintSet startSet = container.getConstraintSet(R.layout.fragment_menu);
startSet.setVisibility(R.id.fab_done, visibility);
}
Hope this helps in the meantime.
The bug is now fixed! Go and live your merry life without any visibility glitches :)
For future readers: This was known bug in MotionLayout where the state reset when the user touched something. Nicolas is talking about this around here: https://youtu.be/r8cYDlBOPaA?t=2276
The team fixed it in Alpha 4.