1

I have an activity where there is an imageView at the top and a recyclerview at the bottom of the imageview. I used MotionLayout to animate the imageView's bottom constraints to top of the screen and recyclerview fill the screen, when I scroll the recyclerview. Everything works fine. But, what I want is that when the recyclerview is empty, I don't want animation to happen. Based on this document and this answer, I used this code:

motionLayout.getTransition(R.id.yourTransition).setEnable(false);

But, this code is not working for me. Even if I add this code, animation still happens. What is wrong with this code? Am I missing something?

eegooDeveloper
  • 395
  • 5
  • 12

2 Answers2

2

motionLayout.enableTransition(R.id.transition, false)

0

Your code is correct. I had same issue on constraintlayout:2.0.0-beta3 (downgrade to beta2 didn't help).

I found workaround:

motionLayout.setTransition(-1, -1)