Skip to content

Commit f5d05b0

Browse files
committed
Fixes #3, counting error when there are child views with visibility set to GONE.
1 parent 0a369e4 commit f5d05b0

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

flowlayout/src/main/java/com/nex3z/flowlayout/FlowLayout.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,12 @@ protected void onLayout(boolean changed, int l, int t, int r, int b) {
213213
int childNum = mChildNumForRow.get(row);
214214
int rowHeight = mHeightForRow.get(row);
215215
float spacing = mHorizontalSpacingForRow.get(row);
216-
for (int i = 0; i < childNum; i++) {
216+
for (int i = 0; i < childNum && childIdx < getChildCount();) {
217217
View child = getChildAt(childIdx++);
218218
if (child.getVisibility() == GONE) {
219219
continue;
220+
} else {
221+
i++;
220222
}
221223

222224
LayoutParams childParams = child.getLayoutParams();

0 commit comments

Comments
 (0)