From 38848ca3a9527e62eef1816770d25e7382cc4e4e Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Tue, 8 Oct 2013 12:03:44 -0700 Subject: [PATCH] Offsetting the CellLayout by the remainder space to center it. (Bug 11030678) Change-Id: Ib83a982498159c21fef5dd8ecc40ac2287d31c60 --- src/com/android/launcher3/CellLayout.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java index 72a6ce2e10..1d10553f7b 100644 --- a/src/com/android/launcher3/CellLayout.java +++ b/src/com/android/launcher3/CellLayout.java @@ -1009,11 +1009,13 @@ public class CellLayout extends ViewGroup { @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { + int offset = getMeasuredWidth() - getPaddingLeft() - getPaddingRight() - + (mCountX * mCellWidth); + int left = getPaddingLeft() + (int) Math.ceil(offset / 2f); + int top = getPaddingTop(); int count = getChildCount(); for (int i = 0; i < count; i++) { View child = getChildAt(i); - int left = getPaddingLeft(); - int top = getPaddingTop(); child.layout(left, top, left + r - l, top + b - t);