0

This is my animation in xml, I tried with android:pivotX="50%" but still I do not get what I want. The point of rotation is wrong. I want the green line to rotate around the middle of the screen.

<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromDegrees="0" android:interpolator="@android:anim/linear_interpolator"
    android:toDegrees="360" android:pivotX="0%" android:pivotY="0%"
    android:repeatCount="5"
    android:duration="5000" android:startOffset="0" />

I want to make animation like this: enter image description here the green line should rotate , and the rotation point should be the center of the screen. How can I do this ?

Lukap
  • 31,523
  • 64
  • 157
  • 244
  • It's unclear what your current symptoms are, but it might be related to this issue: http://code.google.com/p/android/issues/detail?id=22969 – CommonsWare Mar 13 '12 at 13:34
  • 2
    @Lukap shouldn't be both `android:pivotX` and `android:pivotY` set to `"50%"` – Selvin Mar 13 '12 at 13:53

1 Answers1

-2

Use a RotateAnimation, setting the pivot point to the centre of your image.

RotateAnimation anim = new RotateAnimation(0f, 350f, 15f, 15f);
anim.setInterpolator(new LinearInterpolator());
anim.setRepeatCount(Animation.INFINITE);
anim.setDuration(700);

// Start animating the image
final ImageView splash = (ImageView) findViewById(R.id.splash);
splash.startAnimation(anim);

// Later.. stop the animation
splash.setAnimation(null);