Search code examples
androidandroid-coordinatorlayout

CoordinatorLayout anchor view wrong position after change visibility for anchor-to-View


I use CoordinatorLayout for this layout: enter image description here

There are RecycleView with BottomSheetBehavior and AnchorView - View which anchored to first item in RecycleView.

When I scroll RecycleView to top (I listen this with BottomSheetCallback) I change anchorId in AnchorView:

anchorId = View.NO_ID

And when I scroll my RecycleView down I bind AnchorView to first item again. And this works well.

But when I change visibility in FirstItem view I have this problem: The anchored view has wrong position on the screen. (If I scroll list the position is valid again).

How to fix it? enter image description here


Solution

  • I stop using any animations for itemView and it fix my problem.