-Added 3D effect to home screen scrolling

-Added background outline fade in / out
-Modified the feel of scrolling: now using quintic
 interpolator and modified the influence of
 scroll velocity

Change-Id: Ifddcab5223ac20be7d9f800ccf09442d9b4db781
This commit is contained in:
Adam Cohen
2010-09-13 14:49:43 -07:00
parent 163c9c0236
commit 9415d87eda
9 changed files with 263 additions and 124 deletions
+13 -1
View File
@@ -78,6 +78,7 @@ public abstract class PagedView extends ViewGroup {
protected final static int TOUCH_STATE_SCROLLING = 1;
protected final static int TOUCH_STATE_PREV_PAGE = 2;
protected final static int TOUCH_STATE_NEXT_PAGE = 3;
protected final static float ALPHA_QUANTIZE_LEVEL = 0.01f;
protected int mTouchState = TOUCH_STATE_REST;
@@ -367,7 +368,6 @@ public abstract class PagedView extends ViewGroup {
if (mDirtyPageAlpha || (mTouchState == TOUCH_STATE_SCROLLING) || !mScroller.isFinished()) {
int halfScreenSize = getMeasuredWidth() / 2;
int screenCenter = mScrollX + halfScreenSize;
final int childCount = getChildCount();
for (int i = 0; i < childCount; ++i) {
View layout = (View) getChildAt(i);
@@ -391,6 +391,12 @@ public abstract class PagedView extends ViewGroup {
dimAlpha = Math.max(0.0f, Math.min(1.0f, (dimAlpha * dimAlpha)));
float alpha = 1.0f - dimAlpha;
if (alpha < ALPHA_QUANTIZE_LEVEL) {
alpha = 0.0f;
} else if (alpha > 1.0f - ALPHA_QUANTIZE_LEVEL) {
alpha = 1.0f;
}
if (Float.compare(alpha, layout.getAlpha()) != 0) {
layout.setAlpha(alpha);
}
@@ -400,10 +406,16 @@ public abstract class PagedView extends ViewGroup {
}
}
protected void screenScrolled(int screenCenter) {
}
@Override
protected void dispatchDraw(Canvas canvas) {
updateAdjacentPagesAlpha();
int halfScreenSize = getMeasuredWidth() / 2;
int screenCenter = mScrollX + halfScreenSize;
screenScrolled(screenCenter);
// Find out which screens are visible; as an optimization we only call draw on them
// As an optimization, this code assumes that all pages have the same width as the 0th
// page.