Android MotionLayout state not updating when changing constraint programatically

I found a solution!

The solution provided by Phan Van Linh does not work for me (I am using 2.0.0-beta1 constraint version)

Just call .requestLayout() on view you just changed visibility(or other view properties) So in your example:

motion_layout.getConstraintSet(R.id.base)?.let {
                it.setVisibility(R.id.left_to_right_text, View.INVISIBLE)
                yourView.requestLayout() // <-- this line
            }

Due to documentation for requestLayout method it will go through all view`s hierarchy currently in a layout pass.