Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android:staggergridlayout while moving up shuffles

I am using staggered grid layout. the following is the code:

StaggeredGridLayoutManager glm= new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
glm.setGapStrategy(StaggeredGridLayoutManager.GAP_HANDLING_NONE);

I am using GAP_HANDLING_NONE to avoid images swapping from one column to other.

When I start the app, the beginning of the screen is:

enter image description here

After scrolling down to bottom and when I return to the top. randomly the following three images show the layout (it keeps varying)

enter image description here

enter image description here

enter image description here

like image 235
Santhosh Avatar asked Sep 15 '16 05:09

Santhosh


1 Answers

Staggered grids are likely to have gaps at the edges of the layout. To avoid these gaps, StaggeredGridLayoutManager can offset spans independently or move items between spans. You can control this behavior via setGapStrategy(int):

StaggeredGridLayoutManager sGrid = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
sGrid.setGapStrategy(StaggeredGridLayoutManager.GAP_HANDLING_MOVE_ITEMS_BETWEEN_SPANS);

I hope this will help a buddy.

like image 120
Kalpesh Rupani Avatar answered Oct 31 '22 03:10

Kalpesh Rupani