I want to change the default animation of a ProgressBar, so I added a custom style in my theme:
styles.xml
<style name="ProgressTheme" parent="@android:style/Widget.ProgressBar.Large">
<item name="android:indeterminateDrawable">@drawable/spinner_holo_light</item>
</style>
I am calling this style inside my ProgressBar with the following:
ProgressBar.xml
<ProgressBar
android:id="@+id/loadingProgressBar"
style="@style/ProgressTheme"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
The problem lies inside the spinner_holo_light.xml:
If I use the following, everything works fine on devices with os 3.0+, but the progress does not rotate on older os versions:
spinner_holo_light.xml
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/spinner_76_inner_holo"
android:fromDegrees="720"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="0" />
But if I use animate-rotate instead, the animation works on every os version, but the result is a very laggy animation.
<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/spinner_76_inner_holo"
android:fromDegrees="720"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="0" />
What do you think about it? Am I doing something wrong here?
On older devices it is a problem when
android:fromDegreesis bigger thanandroid:toDegressin<rotate>. Try swapping the values:Alternatively, you can try setting it as infinite:
The animation might be laggy on older devices. To fix this add
android:animationResolutionto the style: