派生Animation,新建了一个动画类,在applyTransformation方法里用android.graphics.Camera旋转一个角度。这个动画类放在View里很正常,用View.startAnimation(Animation),
但是用Activity.overridePendingTransition(int, int),旋转的时候好像旋转轴变了。同样的代码,为什么效果不一样?
但是用Activity.overridePendingTransition(int, int),旋转的时候好像旋转轴变了。同样的代码,为什么效果不一样?
解决方案 »
- 新人求助,ecplise没有提示错误,但是生成的apk安装之后不能运行
- @android:id/list 和@+id/android:list的区别。
- android中http get请求总是超时怎么办?
- listview item显示倒计时
- 避免onDraw(Canvas canvas)的重复性画图,急啊!
- 求教android多点触摸问题
- 求高手解答,为啥我按教程写的这个下载程序不能完美执行
- 程序编译后,重新签名安装出现"应用程序未安装
- 使用ViewPager 加载两个窗体,如果重新加载
- 关于Android开发的一个数学功能的实现
- 自定义Dialog的问题 真心求教 急急急!!!!!!!!!
- 设计程序时,如何把自己的数据设计为共享?
package com.xxx.animation;import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Camera;
import android.graphics.Matrix;
import android.util.AttributeSet;
import android.view.animation.Animation;
import android.view.animation.Transformation;public class FakeRotateXAnimation extends Animation
{
private final int mPivotYType;
private final float mPivotYValue; private float mPivotY = 0.0f; private final float mFromDegrees;
private final float mToDegrees; private float mSemiWidth = 0.0f; private final Camera mCamera;// public FakeRotateXAnimation(Context context, AttributeSet attrs)
// {
// super(context, attrs);
//
// TypedArray a = context.obtainStyledAttributes(attrs,
// com.android.internal.R.styleable.FakeRotateXAnimation);
//
// mFromDegrees = a.getFloat(
// com.android.internal.R.styleable.FakeRotateXAnimation_fromDegrees, 0.0f);
// mToDegrees = a.getFloat(com.android.internal.R.styleable.FakeRotateXAnimation_toDegrees, 0.0f);
//
// Description d = Description.parseValue(a.peekValue(
// com.android.internal.R.styleable.FakeRotateXAnimation_pivotY));
// mPivotYType = d.type;
// mPivotYValue = d.value;
//
// a.recycle();
//
// mCamera = new Camera();
// } public FakeRotateXAnimation(float fromDegrees, float toDegrees, float pivotY)
{
this(fromDegrees, toDegrees, ABSOLUTE, pivotY);
} public FakeRotateXAnimation(float fromDegrees, float toDegrees,
int pivotYType, float pivotYValue)
{
this.mFromDegrees = fromDegrees;
this.mToDegrees = toDegrees; this.mPivotYType = pivotYType;
this.mPivotYValue = pivotYValue; mCamera = new Camera();
} @Override
protected void applyTransformation(float interpolatedTime, Transformation t)
{
final float fromDegrees = mFromDegrees;
final float pivotY = mPivotY;
final float semiWidth = mSemiWidth;
final Camera camera = mCamera; final Matrix matrix = t.getMatrix();
final float degrees = fromDegrees + (mToDegrees - fromDegrees)
* interpolatedTime; camera.save();
camera.rotateX(degrees);
camera.getMatrix(matrix);
camera.restore(); matrix.preTranslate(-semiWidth, -pivotY);
matrix.postTranslate(semiWidth, pivotY);
} @Override
public void initialize(int width, int height, int parentWidth,
int parentHeight)
{
super.initialize(width, height, parentWidth, parentHeight); this.mPivotY = this.resolveSize(mPivotYType, mPivotYValue, height,
parentHeight);
this.mSemiWidth = width / 2;
}
}这个动画,给view显示地很完美,直接给activity就一塌糊涂,到底为什么?
overridePendingTransition它本身是针对整个Activity的,而View.startAnimation是只是针对这个view的,使用overridePendingTransition让其旋转,它可能找不到其中心点,所以比较乱!
其实,我也在纠结中...