1

I have a ProgressBar (the round shape one) and it spins very fast, how do I change it to spin at a slower speed?

(It is running indefinitely)


Here is my XML of ProgressBar:

<ProgressBar
        android:id="@+id/progressBar"
        style="@style/Widget.AppCompat.ProgressBar"
        android:layout_width="409dp"
        android:layout_height="710dp"
        android:indeterminate="false"
        android:padding="36dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />
4
  • you can change interpolator to ease-in or slow-in slow out or something else it won't change speed but will make it look better in many ways Commented Jun 25, 2022 at 5:55
  • Can you share your .xml file please? Commented Jun 25, 2022 at 7:10
  • @HalilSahin I have edited the question to include the xml code now Commented Jun 25, 2022 at 8:16
  • Please visit this docs developer.android.com/reference/android/widget/… Commented Jun 25, 2022 at 8:35

2 Answers 2

1

Add a .xml file under /drawable path, like: drawable/circular_spinner.xml circular_spinner:

<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:drawable="@drawable/spinner"
    android:interpolator="@android:anim/linear_interpolator"
    android:fromDegrees="0"
    android:pivotX="50%"
    android:pivotY="50%"
    android:repeatCount="infinite"
    android:toDegrees="3600"
    android:duration="1000"/>

Change the toDegrees and duration to control the speed of the spinning. Then call it in your progressbar layout.

<ProgressBar
        android:id="@+id/progressBar"
        style="@style/Widget.AppCompat.ProgressBar"
        android:layout_width="409dp"
        android:layout_height="710dp"
        android:indeterminate="false"
        android:padding="36dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        android:indeterminateDrawable="@drawable/circular_spinner"
        app:layout_constraintTop_toTopOf="parent"/>
Sign up to request clarification or add additional context in comments.

Comments

0

See also change ProgressBar fps in Android:

<ProgressBar
    android:indeterminateDuration="1000"

Old answer <rotate android:duration="1000"/> doesn't work now.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.