Home > Mobile >  Android RecyclerView + drakeet. Multitype complex layout implementation flow waterfall, flicker, the
Android RecyclerView + drakeet. Multitype complex layout implementation flow waterfall, flicker, the

Time:10-02

There are bosses with multitype implement complex layout, complex layout contains waterfalls flow? Slide down the time, position disturbance, flashing,

recyclerView complex layout adapter : implementation 'me. Drakeet. Multitype: multitype: 3.4.4'
recyclerView manager Settings :
StaggeredGridLayoutManager layoutManager=new StaggeredGridLayoutManager (2, StaggeredGridLayoutManager. VERTICAL);
LayoutManager. SetGapStrategy (StaggeredGridLayoutManager. GAP_HANDLING_NONE);

LayoutManager. SetAutoMeasureEnabled (true);
MRecyclerView. SetHasFixedSize (true);
MRecyclerView. SetItemAnimator (null);

MRecyclerView. AddOnScrollListener (new RecyclerView. OnScrollListener () {
@ Override
Public void onScrollStateChanged (RecyclerView RecyclerView, int newState because) {
Super. OnScrollStateChanged (recyclerView, newState because);
LayoutManager. InvalidateSpanAssignments ();
}
});

Problems:
1, if set the gridView effect item, sliding, finally a blank will be filled with and the first white space, the brush to the top, because the set invalidateSpanAssignments (), interface will be the same, but can see the obvious change effect,

2, falls into decline, set up StaggeredGridLayoutManager. GAP_HANDLING_NONE, but item will position disorder, sliding layoutManager. When invalidateSpanAssignments (); Request a new layout, flashing effect obviously, slide to the bottom in sliding upwards, at the top of the waterfall flow effect, can see the top there is a white space,


CodePudding user response:

Implementation 'me. Drakeet. Multitype: multitype: 3.4.4' is widely used in project, do not change, complex layout can include (row shows two item of the gridView effect, a line of two waterfalls flow effect, a line of a view of the effect, a line is the effect of transverse recyclerView)