diff options
author | Michael Jurka <mikejurka@google.com> | 2011-06-02 16:41:34 -0700 |
---|---|---|
committer | Michael Jurka <mikejurka@google.com> | 2011-06-02 16:41:34 -0700 |
commit | 2478480a9724804fd363dfa99c42ddfba4c46acc (patch) | |
tree | 7db527cb13409b33967a769271013421994573c5 /src/com | |
parent | 32271c3d20939d4fa02d4c84e1d95cefd5c183fd (diff) | |
download | android_packages_apps_Trebuchet-2478480a9724804fd363dfa99c42ddfba4c46acc.tar.gz android_packages_apps_Trebuchet-2478480a9724804fd363dfa99c42ddfba4c46acc.tar.bz2 android_packages_apps_Trebuchet-2478480a9724804fd363dfa99c42ddfba4c46acc.zip |
Fixing bug with layout of PagedViewCellLayoutChildren
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/launcher2/PagedViewCellLayout.java | 14 | ||||
-rw-r--r-- | src/com/android/launcher2/PagedViewCellLayoutChildren.java | 15 |
2 files changed, 15 insertions, 14 deletions
diff --git a/src/com/android/launcher2/PagedViewCellLayout.java b/src/com/android/launcher2/PagedViewCellLayout.java index 1ba5c053b..d715ee35f 100644 --- a/src/com/android/launcher2/PagedViewCellLayout.java +++ b/src/com/android/launcher2/PagedViewCellLayout.java @@ -189,8 +189,6 @@ public class PagedViewCellLayout extends ViewGroup implements Page { } protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - // TODO: currently ignoring padding - int widthSpecMode = MeasureSpec.getMode(widthMeasureSpec); int widthSpecSize = MeasureSpec.getSize(widthMeasureSpec); @@ -233,10 +231,8 @@ public class PagedViewCellLayout extends ViewGroup implements Page { widthGap = heightGap = minGap; } - int newWidth = mPaddingLeft + mPaddingRight + (mCellCountX * cellWidth) + - ((mCellCountX - 1) * widthGap); - int newHeight = mPaddingTop + mPaddingBottom + (mCellCountY * cellHeight) + - ((mCellCountY - 1) * heightGap); + int newWidth = (mCellCountX * cellWidth) + ((mCellCountX - 1) * widthGap); + int newHeight = (mCellCountY * cellHeight) + ((mCellCountY - 1) * heightGap); final int count = getChildCount(); for (int i = 0; i < count; i++) { @@ -248,7 +244,8 @@ public class PagedViewCellLayout extends ViewGroup implements Page { child.measure(childWidthMeasureSpec, childheightMeasureSpec); } - setMeasuredDimension(newWidth, newHeight); + setMeasuredDimension(newWidth + mPaddingLeft + mPaddingRight, + newHeight + mPaddingTop + mPaddingBottom); } int getContentWidth() { @@ -278,7 +275,8 @@ public class PagedViewCellLayout extends ViewGroup implements Page { int count = getChildCount(); for (int i = 0; i < count; i++) { View child = getChildAt(i); - child.layout(0, 0, r - l, b - t); + child.layout(mPaddingLeft, mPaddingTop, + r - l - mPaddingRight, b - t - mPaddingBottom); } } diff --git a/src/com/android/launcher2/PagedViewCellLayoutChildren.java b/src/com/android/launcher2/PagedViewCellLayoutChildren.java index 92ff46184..0907c6058 100644 --- a/src/com/android/launcher2/PagedViewCellLayoutChildren.java +++ b/src/com/android/launcher2/PagedViewCellLayoutChildren.java @@ -92,8 +92,8 @@ public class PagedViewCellLayoutChildren extends ViewGroup { PagedViewCellLayout.LayoutParams lp = (PagedViewCellLayout.LayoutParams) child.getLayoutParams(); lp.setup(mCellWidth, mCellHeight, mWidthGap, mHeightGap, - ((ViewGroup)getParent()).getPaddingLeft(), - ((ViewGroup)getParent()).getPaddingTop()); + getPaddingLeft(), + getPaddingTop()); int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(lp.width, MeasureSpec.EXACTLY); @@ -111,18 +111,21 @@ public class PagedViewCellLayoutChildren extends ViewGroup { int count = getChildCount(); int offsetX = 0; - if (mCenterContent) { + if (mCenterContent && count > 0) { // determine the max width of all the rows and center accordingly - int maxRowWidth = 0; + int maxRowX = 0; + int minRowX = Integer.MAX_VALUE; for (int i = 0; i < count; i++) { View child = getChildAt(i); if (child.getVisibility() != GONE) { PagedViewCellLayout.LayoutParams lp = (PagedViewCellLayout.LayoutParams) child.getLayoutParams(); - maxRowWidth = Math.max(maxRowWidth, lp.x + lp.width); + minRowX = Math.min(minRowX, lp.x); + maxRowX = Math.max(maxRowX, lp.x + lp.width); } } - offsetX = (getMeasuredWidth() / 2) - (maxRowWidth / 2); + int maxRowWidth = maxRowX - minRowX; + offsetX = (getMeasuredWidth() - maxRowWidth) / 2; } for (int i = 0; i < count; i++) { |