我想沿x轴旋转视图。我尝试执行以下操作:
AnimationSet anim=new AnimationSet(true);
RotateAnimation rotate=new RotateAnimation(0.0f,-10.0f,RotateAnimation.ABSOLUTE,0.5f,RotateAnimation.RELATIVE_TO_SELF,0.5f);
rotate.setFillAfter(true);
rotate.setDuration(5000);
rotate.setRepeatCount(0);
anim.addAnimation(rotate);
View relatv1=(View)findViewById(R.id.relativeLayout1);
relatv1.setAnimation(anim);
但我改为视图沿y轴旋转。我如何完成x轴旋转?
答案 0 :(得分:6)
使用像这样的ObjectAnimator:
ObjectAnimator animation = ObjectAnimator.ofFloat(view, "rotationX", 0.0f, 360f);
animation.setDuration(5000);
animation.setRepeatCount(ObjectAnimator.INFINITE);
animation.setInterpolator(new AccelerateDecelerateInterpolator());
animation.start();
答案 1 :(得分:1)