Skip to content Skip to sidebar Skip to footer

How Can I Rotate A View By Y-axis In Android?

In my app, i would like rotate an ImageView by setRotationY(). In fact, it does. Just like from b to d, mirror effect and when i use setRotation(45) before setRotationY(), the resu

Solution 1:

ObjectAnimator animation = ObjectAnimator.ofFloat(view, "rotationY", 0.0f, 360f);
    animation.setDuration(3600);
    animation.setRepeatCount(ObjectAnimator.INFINITE);
    animation.setInterpolator(new AccelerateDecelerateInterpolator());
    animation.start();

Solution 2:

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);

Obviously, you could just put your imageView there


Post a Comment for "How Can I Rotate A View By Y-axis In Android?"