I\'ve created a layout with an image view and a web view. The web view is set to have a default visibility of gone. When the activity fires up it displays the image view fir
You can also simply use the Rotate animation feature. That runs a specific animation, for a pre-determined amount of time, on an ImageView.
Animation rotate = AnimationUtils.loadAnimation([context], R.anim.rotate_picture);
splash.startAnimation(rotate);
Then create an animation XML file in your res/anim called rotate_picture with the content:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<rotate
android:fromDegrees="0"
android:toDegrees="360"
android:duration="5000"
android:pivotX="50%"
android:pivotY="50%">
</rotate>
</set>
Now unfortunately, this will only run it once. You'll need a loop somewhere to make it repeat the animation while it's waiting. I experimented a little bit and got my program stuck in infinite loops, so I'm not sure of the best way to that. EDIT: Christopher's answer provides the info on how to make it loop properly, so removing my bad suggestion about separate threads!
I have found out, that if you use the .getWidth/2 etc... that it won't work you need to get the number of pixels the image is and divide it by 2 yourself and then just type in the number for the last 2 arguments.
so say your image was a 120 pixel by 120 pixel square, ur x and y would equal 60 pixels. so in your code, you would right:
RotateAnimation anim = new RotateAnimation(0f, 350f, 60f, 60f);
anim.setInterpolator(new LinearInterpolator());
anim.setRepeatCount(Animation.INFINITE);
anim.setDuration(700);
and now your image will pivot round its center.
One way - split you image into N rotating it slightly every time. I'd say 5 is enough. then create something like this in drawable
<animation-list android:id="@+id/handimation" android:oneshot="false"
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/progress1" android:duration="150" />
<item android:drawable="@drawable/progress2" android:duration="150" />
<item android:drawable="@drawable/progress3" android:duration="150" />
</animation-list>
code start
progress.setVisibility(View.VISIBLE);
AnimationDrawable frameAnimation = (AnimationDrawable)progress.getDrawable();
frameAnimation.setCallback(progress);
frameAnimation.setVisible(true, true);
code stop
AnimationDrawable frameAnimation = (AnimationDrawable)progress.getDrawable();
frameAnimation.stop();
frameAnimation.setCallback(null);
frameAnimation = null;
progress.setVisibility(View.GONE);
more here