问题描述
我想围绕z平面旋转图像?像这样
在this block的帮助下
我能够做到
但不能满足我的以下要求
- 此图像仅在xy平面中旋转,而不在z平面中旋转
- 此图像围绕其中心点旋转,而不围绕另一个图像中心点
- 此旋转不是360度
更新
我能够做到
使用此代码
final ValueAnimator animator = ValueAnimator.ofFloat(360.0f,0.0f );
animator.setDuration(5000);
animator.addUpdateListener(valueAnimator -> {
float value = (Float) animator.getAnimatedValue();
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
float cx = metrics.widthPixels / 2;
float cy = metrics.heightPixels / 2;
float x = (float) (cx + radious * Math.cos((float) Math.toRadians(value))); // center x in arc
float y = (float) (cy + radious * Math.sin((float) Math.toRadians(value))); // center y in arc
x -= (button.getWidth() / 2);
y -= (button.getHeight() / 2);
button.setX(x);
button.setY(y);
});
animator.start();
并且能够做到
使用以下代码
public FlipAnimation(View view) {
this.view = view;
setDuration(5000);
setFillAfter(false);
setInterpolator(new AccelerateDecelerateInterpolator());
}
@Override
public void initialize(int width,int height,int parentWidth,int parentHeight) {
super.initialize(width,height,parentWidth,parentHeight);
centerX = width / 2;
centerY = height / 2;
camera = new Camera();
}
@Override
protected void applyTransformation(float interpolatedTime,Transformation t) {
final double radians = Math.PI * interpolatedTime;
float degrees = (float) (360.0 * radians / Math.PI);
final Matrix matrix = t.getMatrix();
camera.save();
camera.rotateY(degrees);
camera.getMatrix(matrix);
camera.restore();
matrix.preTranslate(-centerX,-centerY);
matrix.postTranslate(centerX,centerY);
}
但是我需要将它们结合起来以获得期望的结果。我该如何实现
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)