13

I have a FrameLayout which I replace on activity create with fragment where I show and hide some of the views with layout animation change, this works well, but I have a FloatingActionButton anchored to the frame layout and when the layout animates on hiding or showing view the fab flickers, as if there was no animation and those views dissapeared immediately, then goes back and animates with the view.

This really breaks the smoothnes of the whole transition so my question is did anyone else experience this? And is there a fix or workaround for this bug?

TheDivider
  • 131
  • 4
  • 4
    I'm seeing something similar. I have a view in an AppBarLayout that I show and hide. The whole layout underneath the AppBar flashes up quickly before animating up. Did you ever figure this out? – Flyview Mar 08 '16 at 21:24

1 Answers1

4

This issue still seems to exist in SDK 29 with certain elements, such as those with innate transitions. The way I've fixed it is by applying the below flags to the CoordinatorLayout ViewGroup after setting the attribute android:animateLayoutChanges="true".

  cLayout.getLayoutTransition().disableTransitionType(LayoutTransition.APPEARING);
  cLayout.getLayoutTransition().disableTransitionType(LayoutTransition.DISAPPEARING);

This way, the transitions are not duplicated for the views that already include them.

Depending on your situation, you may consider disabling the other transition types instead: LayoutTransition.CHANGE_APPEARING

LayoutTransition.CHANGE_DISAPPEARING

Bryan W
  • 1,112
  • 15
  • 26