diff options
author | Michael Jurka <mikejurka@google.com> | 2011-06-02 16:41:34 -0700 |
---|---|---|
committer | Michael Jurka <mikejurka@google.com> | 2011-06-03 17:56:20 -0700 |
commit | 9bfe2b2646f3849f5463c63876c184e820a7f03b (patch) | |
tree | cec0544001a8e82bb54c29e575a4c94f02fd04e8 /src/com/android/launcher2/PagedViewCellLayoutChildren.java | |
parent | dcfc25ca5f5dd3f867e929e34605564162128b45 (diff) | |
download | android_packages_apps_Trebuchet-9bfe2b2646f3849f5463c63876c184e820a7f03b.tar.gz android_packages_apps_Trebuchet-9bfe2b2646f3849f5463c63876c184e820a7f03b.tar.bz2 android_packages_apps_Trebuchet-9bfe2b2646f3849f5463c63876c184e820a7f03b.zip |
Fixing bug with layout of PagedViewCellLayoutChildren
Change-Id: I3fa34ad500632c4b257973aca9be0cb1bda5884a
Diffstat (limited to 'src/com/android/launcher2/PagedViewCellLayoutChildren.java')
-rw-r--r-- | src/com/android/launcher2/PagedViewCellLayoutChildren.java | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/com/android/launcher2/PagedViewCellLayoutChildren.java b/src/com/android/launcher2/PagedViewCellLayoutChildren.java index 6333f7f2e..1afdd03cf 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++) { |