我将 etsy/AndroidStaggeredGrid 用于 staggeredGrid 视图。如果我在网格中有一个项目并尝试向下和向上滚动,我将面临非常严重的问题,我根本看不到列表项。如果有人知道这个问题,你能提供任何帮助吗?
谢谢
我将 etsy/AndroidStaggeredGrid 用于 staggeredGrid 视图。如果我在网格中有一个项目并尝试向下和向上滚动,我将面临非常严重的问题,我根本看不到列表项。如果有人知道这个问题,你能提供任何帮助吗?
谢谢
交错网格视图.class
只需尝试添加此getChildCount()>1条件:
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);
        }
    }