Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make imageview constantly spin? [closed]

<ImageView
      android:id="@+id/imageView1"
      android:layout_width="300dp"
      android:layout_height="300dp"
      android:src="@drawable/zaid1"
      android:layout_centerVertical="true"
      android:layout_centerHorizontal="true" />

I have an imageview in the middle of an activity, how would I make it so it rotates 360 degrees endlessly?

like image 666
Aditya Pandey Avatar asked Sep 17 '15 22:09

Aditya Pandey


People also ask

What is the purpose of the Imageview?

Displays image resources, for example Bitmap or Drawable resources. ImageView is also commonly used to apply tints to an image and handle image scaling. To learn more about Drawables, see: Drawable Resources.


1 Answers

Try to use RotateAnimation:

RotateAnimation rotateAnimation = new RotateAnimation(0, 360f,
    Animation.RELATIVE_TO_SELF, 0.5f,
    Animation.RELATIVE_TO_SELF, 0.5f);

rotateAnimation.setInterpolator(new LinearInterpolator());
rotateAnimation.setDuration(500);
rotateAnimation.setRepeatCount(Animation.INFINITE);

findViewById(R.id.imageView1).startAnimation(rotateAnimation);
like image 113
stfbee Avatar answered Oct 03 '22 00:10

stfbee