1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) {
int offsetWidth = 0; int offsetHeight = 0;
int right = 0;
for (int i = 0; i < getChildCount(); i++) { View childView = getChildAt(i); int measuredWidth = childView.getMeasuredWidth(); int measuredHeight = childView.getMeasuredHeight(); if (offsetWidth + measuredWidth <= r) { childView.layout(offsetWidth, offsetHeight, measuredWidth + offsetWidth, measuredHeight + offsetHeight);
offsetWidth += measuredWidth; } else { offsetHeight += measuredHeight; offsetWidth = 0;
childView.layout(offsetWidth, offsetHeight, measuredWidth + offsetWidth, measuredHeight + offsetHeight);
offsetWidth += measuredWidth; } }
Log.e(TAG, "onLayout: changed: " + changed + ", l: " + l + ", t: " + t + ", r: " + r + ", b: " + b); }
|