According to the Building a RecyclerView LayoutManager article I have created own custom layout manager for RecyclerView, but due to a few documentation available i can't find a way to force recycle view rebuild animation inside from layout manager ( just like animations when notifyItemInserted or notifyItemDeleted is used). Such animations are controlled by recyclerView and its item animators, developer only can control position of items.
So i have a method fill
, which performs placing child views according to current scroll position and state of layout manager. Such method is called from two places,
in onLayoutChildren ( this method is called when layout manager performs initialization placing of items or when data set was changed)
@Override public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) { detachAndScrapAttachedViews(recycler); fill(recycler); }
in scrollVerticallyBy
/** calculate offset of views while scrolling, layout items on new places*/ @Override public int scrollVerticallyBy(int dy, RecyclerView.Recycler recycler, RecyclerView.State state) { dy = scrollVerticallyInternal(dy); offsetChildrenVertical(-dy); if (condition) { //todo refactor it, blinking now without animation. detachAndScrapAttachedViews(recycler); } fill(recycler); return dy; }
And i want in case of some condition
perform a bit more complex transition for some views and with animation.
It may be reached if somehow initiate layouting childrens flow, when onLayoutChildren
method will be invoked by RecyclerView.
I'm able to do this with detachAndScrapAttachedViews(recycler)
and that initiates onLayoutChildren
and running default fill
process, but such transition will be performed instantly without any animation.
Is it possible to force recyclerView (or layout manager) inside from layout manager to run its animations?