View 3D翻转
原生RotateAnimation
原生RotateAnimation 只能是平面的旋转,实现不了3D效果。
RotateAnimation rotateAnimation = new RotateAnimation(0f, 359f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
rotateAnimation.setDuration(2000);
rotateAnimation.setInterpolator(new LinearInterpolator());
rotateAnimation.setFillAfter(true);
rotateAnimation.setRepeatCount(-1);
//rotateAnimation.setRepeatMode(ValueAnimator.REVERSE);
rotateAnimation.setRepeatMode(ValueAnimator.RESTART);
// mDefaultLayout.setAnimation(rotateAnimation);
mDefaultLayout.startAnimation(rotateAnimation);
Matrix视图变换
1 自定义的Animation 重写 applyTransformation(float interpolatedTime, Transformation t) 方法
interpolatedTime : 因子 0 - > 1
2 主要是通过对android.graphics.Camera的操作来实现3D的变化效果。
- 要旋转的布局沿Y轴旋