在我的应用程序中,我想将
ImageView
旋转 setRotationY()
。事实上,确实如此。就像从b到d一样,镜像效果,当我在setRotation(45)
之前使用setRotationY()
时,结果是setRotationY
是根据设备Y-axis
,而我想要根据自我视图的rotationY
。
如何?你能指导我吗? 谢谢!
ObjectAnimator animation = ObjectAnimator.ofFloat(view, "rotationY", 0.0f, 360f);
animation.setDuration(3600);
animation.setRepeatCount(ObjectAnimator.INFINITE);
animation.setInterpolator(new AccelerateDecelerateInterpolator());
animation.start();
似乎这是获得类似结果的唯一方法:
handler1 执行无限循环。
scaleDownX.setDuration(1500); 创建图像沿中轴旋转 180 度的错觉,持续时间为 1500ms
scaleDownX2.setDuration(1500); 创建图像沿中轴随后旋转 180 度的错觉,持续时间为 1500ms
ImageView golden1 = (ImageView) findViewById(R.id.golden1);
final Handler handler1 = new Handler();
handler1.postDelayed(new Runnable() {
@Override
public void run() {
ObjectAnimator scaleDownX = ObjectAnimator.ofFloat(golden1, "scaleX", 0, -1f);
scaleDownX.setDuration(1500);
scaleDownX.start();
final Handler handler2 = new Handler();
handler2.postDelayed(new Runnable() {
@Override
public void run() {
ObjectAnimator scaleDownX2 = ObjectAnimator.ofFloat(golden1, "scaleX", -1f, 0);
scaleDownX2.setDuration(1500);
scaleDownX2.start();
}
}, 1500);
handler1.postDelayed(this, 3000);
}
}, 100);
RotateAnimation rotate = new RotateAnimation(0, 180, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
rotate.setDuration(5000);
rotate.setInterpolator(new LinearInterpolator());
ImageView image= (ImageView) findViewById(R.id.imageView);
image.startAnimation(rotate);
显然,你可以把你的 imageView 放在那里