Android BottomSheet jumps up when content changes

Viewed 2144

I using BottomSheet in my app. This is a sticky bar aligned to the bottom, and shows total price in collapsed mode. User can drag up to see details. My problem is: When the user change the content (add some stocks to the list) and the layout is changing in the collapsed sticky, its jumps up to the full size. No methods called in the BottomSheetCallback, so the transition animations is not working.

BTW i have the same issue in the CollapsedToolbarLayout.

Anybody can help me to avoid this issue?

UPDATE

This problem caused by android:animateLayoutChanges = "true" in the BottomSheet layout's content. This will cause the same problem in the CollapsedToolbarLayout. I hope this will help somebody :)

2 Answers

Remove android:animateLayoutChanges = "true"

If you want to change layout with an animation, you have to remove android:animateLayoutChanges = "true" in your layout file and call TransitionManager.beginDelayedTransition((ViewGroup) getView().getParent()) before any changes.

In my case, I am using ConstraintLayout without definition of layout_gravity and I am changing visibility of View.

Related