Android Animate Rotate Android Animate Rotate android android

Android Animate Rotate


I ran into the exact same issue. You can exclude those parameters (framesCount and frameDuration), and it may work for you. I tried just excluding them and it animated fine, but the width/height I was setting were not being respected, so I ended up creating a simple rotation animation and an ImageView to apply it to. Here's the animation file (res/anim/clockwise_rotation.xml):

<?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="50%"  android:pivotY="50%"  android:duration="1000"  android:startOffset="0"/>

Then you just inflate your Animation, set repeat count, and start it from the View

Animation rotation = AnimationUtils.loadAnimation(this, R.anim.clockwise_rotation);rotation.setRepeatCount(Animation.INFINITE);myView.startAnimation(rotation);


Instead of creating an animation (more code required, not only XML configuration), use layer-list as drawable resource.It is quite interesting that layer-list is way more fluid than animated-rotate.

<layer-list xmlns:android="http://schemas.android.com/apk/res/android"><item>    <rotate        android:drawable="@drawable/spinner_loading"        android:pivotX="50%"        android:pivotY="50%"        android:fromDegrees="0"        android:toDegrees="360"/></item></layer-list>

Then of course use it in the styles as Mario Lenci wrote:

<style name="YourProgressBarStyle" parent="@android:style/Widget.ProgressBar">    <item name="android:indeterminateDrawable">@drawable/progress_bar_indeterminate</item></style>


I don't know how to work around the private attributes, I have the same problem.

By the way if you want to change those attributes of the ProgressBar:

android:indeterminateOnly="true"android:indeterminateBehavior="cycle"android:indeterminateDuration="3500"android:indeterminateDrawable="@drawable/pia_sivuvator"

you can do it easily with the Styles framework defining in the values/styles.xml file a ProgressBar style extending the standard android one:

<style name="YourProgressBarStyle" parent="@android:style/Widget.ProgressBar">        <item name="android:indeterminateDrawable">@drawable/progress_bar_indeterminate</item></style>

and then applying it to the progress bar in the xml layout file.

...<ProgressBar     android:layout_width="wrap_content"     android:layout_height="wrap_content"     style="@style/YourProgressBarStyle"/>...