Created
December 8, 2015 14:29
-
-
Save easternHong/2cca7227fb699f6b4638 to your computer and use it in GitHub Desktop.
android view layout children
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
protected void onLayout(boolean changed, int l, int t, int r, int b) { | |
int row, col, left, top; | |
for (int i=0; i < getChildCount(); i++) { | |
row = i / mColumnCount; | |
col = i % mColumnCount; | |
View child = getChildAt(i); | |
left = col * child.getMeasuredWidth(); | |
top = row * child.getMeasuredHeight(); | |
child.layout(left, top, left + child.getMeasuredWidth(), top + child.getMeasuredHeight()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment