Steps to reproduce: Run an activity with MotionLayout inside it Transition to a non-initial state Rotate the device or enable/disable dark mode
Observed: The MotionLayout is in it's initial state Expected: The MotionLayout is in the state that was shown before the rotation
Should I put the id of the state inside the savedInstanceState
, and then transition to that state (with 0 duration, so it is instantaneous) inside onCreate
? This approach I think would work but feels a bit hacky, does anyone know a better solution to this problem?
MotionLayout does not automatically save its state. The state of the layout can be quite complex.
The most generic way to save the basic stat of a MotionLayout is to save the bundle returned by getTransitionState() and then call setTransitionState(Bundle b) on restore
Ok, this works like a charm if the motion layout is inside its end state. But if I setTransitionState when the motion layout is supposed to be in its start state, it auto-transitions to the end state. Do you have any suggestions on how to disable this auto-transition behavior? (in the scene file auto transition is not set)
Please see this question for further clarification and code/gif: stackoverflow.com/questions/65048418/…