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:fromDegrees
is bigger than android:toDegress
in <rotate>
. Try swapping the values:
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/spinner_76_inner_holo"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="720" />
Alternatively, you can try setting it as infinite:
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/spinner_76_inner_holo"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="infinite" />
The animation might be laggy on older devices. To fix this add android:animationResolution
to the style:
<style name="ProgressTheme" parent="@android:style/Widget.ProgressBar.Large">
<item name="android:indeterminateDrawable">@drawable/spinner_holo_light</item>
<item name="android:animationResolution">33</item>
</style>
Make transparent background of progress dialog.
Make border less progress dialog.
And customization of color of spinner of circular progress dialog.
http://pankajchunchun.wordpress.com/2011/09/10/customization-of-spinner-progress/
I couldn't get it work on Samsung Galaxy S Plus even adding
<item name="android:animationResolution">33</item>
I was asking something similar to your response @Tomik
Android Progress Bar slow rotation on pre HoneyComb devices
Is it smoothly on all the pre honeycomb devices for sure?
I Solved this Problem by Changing BackGround xml Custom format to indeterminateDrawable
Use android:indeterminateDrawable except android:BackGround
<ProgressBar
android:layout_centerHorizontal = "true"
android:layout_centerVertical = "true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminateDrawable = "@drawable/progressbar"
android:id="@+id/progressBar"
android:indeterminate = "true"/>
And Custom Progressbar XML Code
<?xml version="1.0" encoding="utf-8" ?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="360">
<shape android:shape="ring" android:innerRadiusRatio="3"
android:thicknessRatio="7" android:useLevel="false">
<size android:width="76dip" android:height="76dip" />
<gradient android:type="sweep" android:useLevel="false"
android:startColor="@android:color/transparent"
android:endColor="#00FF00"
android:angle="0" />
</shape>
</rotate>