Skip to content Skip to sidebar Skip to footer

Imageview With Rotate Xml Not Rotating

I am using following code,

Solution 1:

Try this

<ImageViewandroid:id="@+id/imgView"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerInParent="true"android:src="@drawable/animate"/><?xml version="1.0" encoding="utf-8"?><rotatexmlns:android="http://schemas.android.com/apk/res/android"android:fromDegrees="0"android:interpolator="@android:anim/linear_interpolator"android:pivotX="50%"android:pivotY="50%"android:repeatCount="infinite"android:toDegrees="359"android:duration="1000" ></rotate>

  ImageView imgView=(ImageView)findViewById(R.id.imgView);
          Animation rotation = AnimationUtils.loadAnimation(this,  R.drawable.animate);
          imgView.startAnimation(rotation);

Solution 2:

Try doing this in your xml Animation

<?xml version="1.0" encoding="utf-8"?><set xmlns:android="http://schemas.android.com/apk/res/android"
  android:shareInterpolator="false" ><rotate
    android:interpolator="@android:anim/linear_interpolator"
    android:duration="2500"<!-- put any duration you want -->
    android:pivotX="50%"
    android:pivotY="50%"
    android:repeatCount="infinite"
    android:repeatMode="restart"
    android:toDegrees="360" /></set>

Solution 3:

try this

<?xml version="1.0" encoding="utf-8"?><setxmlns:android="http://schemas.android.com/apk/res/android"android:shareInterpolator="false" ><rotateandroid:duration="4000"android:interpolator="@android:anim/linear_interpolator"android:pivotX="50%"android:pivotY="50%"android:repeatCount="infinite"android:repeatMode="restart"android:toDegrees="360" /></set>

Solution 4:

It looks like there are two things that can cause this problem:

  1. AnimationUtils.loadAnimation(this, R.drawable.animate); shouldn't the animate.xml be an animation resource in the animation folder instead of being a drawable?
  2. You are rotating from 90 to 90 degrees. Maybe this is just not doing anything.

Post a Comment for "Imageview With Rotate Xml Not Rotating"