前言
欢迎大家我分享和推荐好用的代码段~~
声明
欢迎转载,但请保留文章原始出处:
CSDN:http://www.csdn.net
雨季o莫忧离:http://blog.csdn.net/luckkof
正文
目前的Launcher桌面滑动时,是没有动画的。如何在Lancher的桌面滑动时添加动画效果?Demo:
请修改Workspace.java的screenScrolled方法,如下:
@Override
protected void screenScrolled(int screenCenter) {
super.screenScrolled(screenCenter);
updatePageAlphaValues(screenCenter);
enableHwLayersOnVisiblePages();
if (mOverScrollX < 0 || mOverScrollX > mMaxScrollX) {
int index = mOverScrollX < 0 ? 0 : getChildCount() - 1;
CellLayout cl = (CellLayout) getChildAt(index);
float scrollProgress = getScrollProgress(screenCenter, cl, index);
cl.setOverScrollAmount(Math.abs(scrollProgress), index == 0);
float rotation = - WORKSPACE_OVERSCROLL_ROTATION * scrollProgress;
cl.setRotationY(rotation);
setFadeForOverScroll(Math.abs(scrollProgress));
if (!mOverscrollTransformsSet) {
mOverscrollTransformsSet = true;
cl.setCameraDistance(mDensity * mCameraDistance);
cl.setPivotX(cl.getMeasuredWidth() * (index == 0 ? 0.75f : 0.25f));
cl.setPivotY(cl.getMeasuredHeight() * 0.5f);
cl.setOverscrollTransformsDirty(true);
}
} else {
if (mOverscrollFade != 0) {
setFadeForOverScroll(0);
}
if (mOverscrollTransformsSet) {
mOverscrollTransformsSet = false;
((CellLayout) getChildAt(0)).resetOverscrollTransforms();
((CellLayout) getChildAt(getChildCount() - 1)).resetOverscrollTransforms();
}
//mtk add (demo)
for (int i = 0; i < getChildCount(); i++) {
View v = getPageAt(i);
if (v != null) {
float scrollProgress = getScrollProgress(screenCenter, v, i);
float rotation = - WORKSPACE_OVERSCROLL_ROTATION * 5 * scrollProgress;
v.setRotation(rotation);
v.setCameraDistance(mDensity * mCameraDistance);
v.setPivotX(v.getMeasuredWidth() * 0.5f);
v.setPivotY(v.getMeasuredHeight());
}
}
//mtk add (demo)
}
}
目前的Launcher桌面滑动时,是没有动画的。如何在Lancher的桌面滑动时添加动画效果?
Demo: