From ea3b5e62a45fb70041ac52f06608acbb96f6af30 Mon Sep 17 00:00:00 2001 From: Raj Yengisetty Date: Mon, 10 Nov 2014 10:35:01 -0800 Subject: Fix layout issues in Trebuchet Change-Id: I834209656b440e90af437ae127070456586d8bd4 --- src/com/android/launcher3/PagedView.java | 33 ++++++++++---------------------- 1 file changed, 10 insertions(+), 23 deletions(-) (limited to 'src/com/android/launcher3/PagedView.java') diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java index b7b0e5219..b314bd19e 100644 --- a/src/com/android/launcher3/PagedView.java +++ b/src/com/android/launcher3/PagedView.java @@ -952,6 +952,8 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc if (DEBUG) Log.d(TAG, "PagedView.onLayout()"); final int childCount = getChildCount(); + int screenWidth = getViewportWidth(); + int offsetX = getViewportOffsetX(); int offsetY = getViewportOffsetY(); @@ -966,10 +968,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc int verticalPadding = getPaddingTop() + getPaddingBottom(); - LayoutParams lp = (LayoutParams) getChildAt(startIndex).getLayoutParams(); - LayoutParams nextLp; - - int childLeft = offsetX + (lp.isFullScreenPage ? 0 : getPaddingLeft()); + int childLeft = offsetX + (screenWidth - getChildWidth(startIndex)) / 2; if (mPageScrolls == null || getChildCount() != mChildCountOnLastLayout) { mPageScrolls = new int[getChildCount()]; } @@ -977,7 +976,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc for (int i = startIndex; i != endIndex; i += delta) { final View child = getPageAt(i); if (child.getVisibility() != View.GONE) { - lp = (LayoutParams) child.getLayoutParams(); + LayoutParams lp = (LayoutParams) child.getLayoutParams(); int childTop; if (lp.isFullScreenPage) { childTop = offsetY; @@ -995,26 +994,14 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc child.layout(childLeft, childTop, childLeft + child.getMeasuredWidth(), childTop + childHeight); - int scrollOffsetLeft = lp.isFullScreenPage ? 0 : getPaddingLeft(); - mPageScrolls[i] = childLeft - scrollOffsetLeft - offsetX; + int scrollOffset = (getViewportWidth() - childWidth) / 2; + mPageScrolls[i] = childLeft - scrollOffset - offsetX; - int pageGap = mPageSpacing; - int next = i + delta; - if (next != endIndex) { - nextLp = (LayoutParams) getPageAt(next).getLayoutParams(); - } else { - nextLp = null; + if (i != endIndex - delta) { + childLeft += childWidth + scrollOffset; + int nextScrollOffset = (getViewportWidth() - getChildWidth(i + delta)) /2; + childLeft += nextScrollOffset; } - - // Prevent full screen pages from showing in the viewport - // when they are not the current page. - if (lp.isFullScreenPage) { - pageGap = getPaddingLeft(); - } else if (nextLp != null && nextLp.isFullScreenPage) { - pageGap = getPaddingRight(); - } - - childLeft += childWidth + pageGap; } } -- cgit v1.2.3