protected int mTouchSlop;
private int mPagingTouchSlop;
private int mMaximumVelocity;
- protected int mPageSpacing;
protected int mPageLayoutPaddingTop;
protected int mPageLayoutPaddingBottom;
protected int mPageLayoutPaddingLeft;
// Drop to delete
private View mDeleteDropTarget;
- private boolean mAutoComputePageSpacing = false;
- private boolean mRecomputePageSpacing = false;
-
// Bouncer
private boolean mTopAlignPageWhenShrinkingForBouncer = false;
TypedArray a = context.obtainStyledAttributes(attrs,
R.styleable.PagedView, defStyle, 0);
- setPageSpacing(a.getDimensionPixelSize(R.styleable.PagedView_pageSpacing, 0));
- if (mPageSpacing < 0) {
- mAutoComputePageSpacing = mRecomputePageSpacing = true;
- }
+
mPageLayoutPaddingTop = a.getDimensionPixelSize(
R.styleable.PagedView_pageLayoutPaddingTop, 0);
mPageLayoutPaddingBottom = a.getDimensionPixelSize(
}
}
setMeasuredDimension(scaledWidthSize, scaledHeightSize);
-
- if (childCount > 0) {
- // Calculate the variable page spacing if necessary
- if (mAutoComputePageSpacing && mRecomputePageSpacing) {
- // The gap between pages in the PagedView should be equal to the gap from the page
- // to the edge of the screen (so it is not visible in the current screen). To
- // account for unequal padding on each side of the paged view, we take the maximum
- // of the left/right gap and use that as the gap between each page.
- int offset = (getViewportWidth() - getChildWidth(0)) / 2;
- int spacing = Math.max(offset, widthSize - offset -
- getChildAt(0).getMeasuredWidth());
- setPageSpacing(spacing);
- mRecomputePageSpacing = false;
- }
- }
- }
-
- public void setPageSpacing(int pageSpacing) {
- mPageSpacing = pageSpacing;
- requestLayout();
}
@Override
// This ensures that when children are added, they get the correct transforms / alphas
// in accordance with any scroll effects.
mForceScreenScrolled = true;
- mRecomputePageSpacing = true;
updateFreescrollBounds();
invalidate();
}
int offset = (getViewportWidth() - getChildWidth(mCurrentPage)) / 2;
if (isLayoutRtl()) {
return (x > (getViewportOffsetX() + getViewportWidth() -
- offset + mPageSpacing));
+ offset));
}
- return (x < getViewportOffsetX() + offset - mPageSpacing);
+ return (x < getViewportOffsetX() + offset);
}
/**
protected boolean hitsNextPage(float x, float y) {
int offset = (getViewportWidth() - getChildWidth(mCurrentPage)) / 2;
if (isLayoutRtl()) {
- return (x < getViewportOffsetX() + offset - mPageSpacing);
+ return (x < getViewportOffsetX() + offset);
}
return (x > (getViewportOffsetX() + getViewportWidth() -
- offset + mPageSpacing));
+ offset));
}
/** Returns whether x and y originated within the buffered viewport */
protected float getScrollProgress(int screenCenter, View v, int page) {
final int halfScreenSize = getViewportWidth() / 2;
- int totalDistance = v.getMeasuredWidth() + mPageSpacing;
+ int offset = (getViewportWidth() - getChildWidth(page)) / 2;
+ int totalDistance = v.getMeasuredWidth() + offset;
int delta = screenCenter - (getScrollForPage(page) + halfScreenSize);
float scrollProgress = delta / (totalDistance * 1.0f);
int newX = 0;
if (slideFromLeft) {
if (i == 0) {
+ int pageSpace = (getViewportWidth() - getChildWidth(i)) / 2;
// Simulate the page being offscreen with the page spacing
oldX = getViewportOffsetX() + getChildOffset(i) - getChildWidth(i)
- - mPageSpacing;
+ - pageSpace;
} else {
oldX = getViewportOffsetX() + getChildOffset(i - 1);
}