From b929a3a6100f09ee2c09f5a9867b6fa91355b70d Mon Sep 17 00:00:00 2001 From: yuchanglo Date: Mon, 19 Oct 2015 14:29:02 -0700 Subject: [PATCH] Update RectangleGridLayout.java Why would you use measureChildWithMargins vs. measureChild? Isn't the margins taken into consideration later on already? --- .../github/channguyen/rl/RectangleGridLayout.java | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/library/src/main/java/com/github/channguyen/rl/RectangleGridLayout.java b/library/src/main/java/com/github/channguyen/rl/RectangleGridLayout.java index 0bd9576..592602e 100644 --- a/library/src/main/java/com/github/channguyen/rl/RectangleGridLayout.java +++ b/library/src/main/java/com/github/channguyen/rl/RectangleGridLayout.java @@ -83,13 +83,7 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { if (child.getVisibility() == View.GONE) { continue; } - measureChildWithMargins( - child, - MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), - 0, - MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), - 0 - ); + measureChild(child, widthMeasureSpec, heightMeasureSpec); final MarginLayoutParams lp = (MarginLayoutParams) child.getLayoutParams(); childMarginWidth += (lp.leftMargin + lp.rightMargin); childMarginHeight += (lp.topMargin + lp.bottomMargin); @@ -101,7 +95,7 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { w = (mw * column) + paddingWidth + childMarginWidth; h = (mh * row) + paddingHeight + childMarginHeight; - // If child decide to give no with or height, use default + // If child decide to give no width or height, use default if (mw == 0) { w = dpToPx(getContext(), DEFAULT_WIDTH) + childMarginWidth; } @@ -157,7 +151,7 @@ protected void onLayout(boolean changed, int l, int t, int r, int b) { // right x + (y + 1) * cw - lp.rightMargin, // bottom - (x + 1) * ch - lp.topMargin + (x + 1) * ch - lp.bottomMargin ); } }