I want to change the default animation of a ProgressBar
, so I added a custom style in my theme:
<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
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:
<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?
How To Make Circle Custom Progress Bar in Android? This example demonstrates how do I make circle custom progress bar in android. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main.xml.
Most of the time, we end up using a ProgressBar as the loading icon while the data gets loaded. Going by the current trend, apps like Reddit, UBER, Foodpanda and Twitter have replaced the commonly used Progress Bar with their application’s icon as the loading icon.
Build and run the app to see the following screen: The skeleton app contains a GoalProgressBar class which extends Android's ProgressBar, but doesn't add any additional functionality. Clicking on the Reset Progress button will update the progress to a new value, which will help us test our changes during development.
activity_main.xml, this is a layout xml file with an indeterminate ProgressBar in the center. It uses the above drawable/circular_spinner.xml as the value of android:indeterminateDrawable
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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With