20

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 :)

Apoth
  • 353
  • 5
  • 13
  • Post your layout and java code here... – Ferdous Ahamed Jul 06 '17 at 09:17
  • 2
    Unfortunately i have a very strong confidentiality contract, so i can not share the code. But i created a sample project, and realised, the main cause: android:animateLayoutChanges = "true" So, if the content is animating the bottomBar (and the collapsed toolbar as well) will open immediately. That is not so good, i need this animations. – Apoth Jul 07 '17 at 09:08
  • @Apoth do you find a solution for this problem? – extmkv Jul 11 '18 at 08:39
  • 2
    @extmkv, yes. The root of my problem is: i started animation on a collapsed layout. You need to check the bottom bar if it is collapsed, and if yes do not start any view animation inside. – Apoth Jul 12 '18 at 19:55
  • 2
    Removing `android:animateLayoutChanges = "true"` fixed the issue. – ymerdrengene Mar 04 '20 at 09:48

2 Answers2

9

Remove android:animateLayoutChanges = "true"

Asiri Hewage
  • 577
  • 3
  • 16
2

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.

Thomas.
  • 91
  • 2
  • 6