etsy/AndroidStaggeredGrid

Item no longer visible when scroll single item.

HareshChhelana opened this issue · 2 comments

I have set items based on web service response and set app:column_count="2" in xml.

Now when i get only single item from web response item shown in StaggeredGridfine but if i scroll StaggeredGridthen item goes away and no longer visible in StaggeredGrid.

is any one face same issue ? or any one help me to resolve this issue ?

Thanks a lot in advance.

I am also facing the same issue apart from that, if the girdview scrolls continuously says 6-7 times. the whole list view is invisible. I am trying to fix this issue but did not get any pointer. Did you get any workaround for this issue?

I recently found solution for this problem, Just try to check child count > 1 in 'offsetChildrenTopAndBottom' in StaggeredGridView class. Check out my peace of code to resolve my problem -

protected void offsetChildrenTopAndBottom(final int offset, final int column) {
if (DBG) Log.d(TAG, "offsetChildrenTopAndBottom: " + offset + " column:" + column);
if(getChildCount()>1) {
final int count = getChildCount();
for (int i = 0; i < count; i++) {
final View v = getChildAt(i);
if (v != null &&
v.getLayoutParams() != null &&
v.getLayoutParams() instanceof GridLayoutParams) {
GridLayoutParams lp = (GridLayoutParams) v.getLayoutParams();
if (lp.column == column) {
v.offsetTopAndBottom(offset);
}
}
}
offsetColumnTopAndBottom(offset, column);
}
}