activity或者view之间调整加个动画
解决方案 »
- 帮忙看下什么问题
- android保存图片问题
- 请问如何屏蔽Android音量加减时弹出的对话框?
- 以下java关于图像的代码的等价android代码是怎么样的?
- android Gallery getIntent().getData
- android 应用计费
- 写了个数据库操作类,运行期却非常麻烦,报怪异错误!
- 使用Ant打包Android项目,打包成功后运行出现空指针
- 【提问】做了一个安卓应用需要连局域网的,之前都是用自己电脑作服务器,能否把服务器放在网上 ?这样就不是连局域网了,要做怎样的改变呢?
- C#FromBase64String 等语句 转换为JAVA怎么写
- 关于加载SO
- 新建的Android项目,怎么没有那个手机背景啊?
protected void dispatchDraw(Canvas canvas) {
boolean restore = false;
// ADW: If using old wallpaper rendering method...
if (!lwpSupport && mWallpaperDrawable != null) {
float x = getScrollX() * mWallpaperOffset;
if (x + mWallpaperWidth < getRight() - getLeft()) {
x = getRight() - getLeft() - mWallpaperWidth;
}
// ADW: added tweaks for when scrolling "beyond bounce limits" :P
if (getScrollX() < 0)
x = getScrollX();
if (getScrollX() > getChildAt(getChildCount() - 1).getRight()
- (getRight() - getLeft())) {
x = (getScrollX() - mWallpaperWidth + (getRight() - getLeft()));
}
// ADW lets center the wallpaper when there's only one screen...
if (!mWallpaperScroll || getChildCount() == 1)
x = (getScrollX() - (mWallpaperWidth / 2) + (getRight() / 2));
final int y = mWallpaperY;
canvas.drawBitmap(mWallpaperDrawable.getBitmap(), x, y, mPaint);
}
if (!mSensemode) {
// If the all apps drawer is open and the drawing region for the
// workspace
// is contained within the drawer's bounds, we skip the drawing.
// This requires
// the drawer to be fully opaque.
if ((mLauncher.isAllAppsVisible()) || mLauncher.isEditMode()) {
return;
}
// ViewGroup.dispatchDraw() supports many features we don't need:
// clip to padding, layout animation, animation listener,
// disappearing
// children, etc. The following implementation attempts to
// fast-track
// the drawing dispatch by drawing only what we know needs to be
// drawn. boolean fastDraw = mTouchState != TOUCH_STATE_SCROLLING
&& mNextScreen == INVALID_SCREEN;
// If we are not scrolling or flinging, draw only the current screen
if (fastDraw) {
drawChild(canvas, getChildAt(mCurrentScreen), getDrawingTime());
} else {
final long drawingTime = getDrawingTime();
// If we are flinging, draw only the current screen and the
// target screen
if (mNextScreen >= 0 && mNextScreen < getChildCount() &&
Math.abs(mCurrentScreen - mNextScreen) == 1) {
drawChild(canvas, getChildAt(mCurrentScreen), drawingTime);
drawChild(canvas, getChildAt(mNextScreen), drawingTime);
} else {
// If we are scrolling, draw all of our children
final int count = getChildCount();
for (int i = 0; i < count; i++) {
int select = AlmostNexusSettingsHelper.getAnimator(getContext());
if (select < 3){
drawChild(canvas, getChildAt(i), getDrawingTime());
}else{
getChildAt(i).invalidate();
drawScreen(canvas, i, getDrawingTime(), select);
}
}
}
}
} else {
long currentTime;
if (startTime == 0) {
startTime = SystemClock.uptimeMillis();
currentTime = 0;
} else {
currentTime = SystemClock.uptimeMillis() - startTime;
}
if (currentTime >= mAnimationDuration) {
isAnimating = false;
if (mStatus == SENSE_OPENING) {
mStatus = SENSE_OPEN;
} else if (mStatus == SENSE_CLOSING) {
mStatus = SENSE_CLOSED;
mSensemode = false;
clearChildrenCache();
unlock();
postInvalidate();
}
} else {
postInvalidate();
}
final int count = getChildCount();
for (int i = 0; i < count; i++) {
int select = AlmostNexusSettingsHelper.getAnimator(getContext());
if (select < 3){
drawChild(canvas, getChildAt(i), getDrawingTime());
}else{
getChildAt(i).invalidate();
drawScreen(canvas, i, getDrawingTime(), select);
}
}
}
if (restore) {
canvas.restore();
}
} /*add by dwj*/
public void drawScreen(Canvas canvas, int screen, long drawingTime, int select) {
int saveCount = canvas.save();
getChildAt(screen).setAlpha(1);
if (mSensemode) {
View child = getChildAt(screen);
if (isAnimating || mStatus == SENSE_OPEN) {
long currentTime = SystemClock.uptimeMillis() - startTime;
Rect r1 = new Rect(0, 0, child.getWidth(), child.getHeight());
RectF r2 = getScaledChild(child);
float x = 0;
float y = 0;
float width = 0;
float alpha = 255;
if (mStatus == SENSE_OPENING) {
alpha = easeOut(currentTime, 0, 100, mAnimationDuration);
x = easeOut(currentTime, child.getLeft(), r2.left, mAnimationDuration);
y = easeOut(currentTime, child.getTop(), r2.top, mAnimationDuration);
width = easeOut(currentTime, child.getRight(), r2.right, mAnimationDuration);
} else if (mStatus == SENSE_CLOSING) {
alpha = easeOut(currentTime, 100, 0, mAnimationDuration);
x = easeOut(currentTime, r2.left, child.getLeft(), mAnimationDuration);
y = easeOut(currentTime, r2.top, child.getTop(), mAnimationDuration);
width = easeOut(currentTime, r2.right, child.getRight(), mAnimationDuration);
} else if (mStatus == SENSE_OPEN) {
x = r2.left;
y = r2.top;
width = r2.right;
alpha = 100;
}
float scale = ((width - x) / r1.width());
canvas.save();
canvas.translate(x, y);
canvas.scale(scale, scale);
mPaint.setAlpha((int) alpha);
canvas.drawRoundRect(
new RectF(r1.left + 5, r1.top + 5, r1.right - 5, r1.bottom - 5), 15f, 15f,
mPaint);
mPaint.setAlpha(255);
child.draw(canvas);
canvas.restore();
} else {
child.draw(canvas);
}
}else{
if (select == 3) { //旋转
final int width = getWidth();
final int scrollWidth = screen * width;
final int scrollX = this.getScrollX();
if (scrollWidth > scrollX + width || scrollWidth + width < scrollX) {
return;
}
final View child = getChildAt(screen);
final int faceIndex = screen;
final float currentDegree = getScrollX() * (angle / getMeasuredWidth());
final float faceDegree = currentDegree - faceIndex * angle;
if (faceDegree > 90 || faceDegree < -90) {
return;
}
final float centerX = (scrollWidth < scrollX) ? scrollWidth + width : scrollWidth;
final float centerY = getHeight() / 2;
final Camera camera = mCamera;
final Matrix matrixX = mMatrix;
canvas.save();
camera.save();
camera.rotateY(-faceDegree);
camera.getMatrix(matrixX);
camera.restore();
matrixX.preTranslate(-centerX, -centerY);
matrixX.postTranslate(centerX, centerY);
canvas.concat(matrixX);
drawChild(canvas, child, drawingTime);
canvas.restore();
} else {
super.dispatchDraw(canvas);
}
}
canvas.restoreToCount(saveCount);
mLastScroll = getScrollX();
}