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)
Edit: 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" />
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"/>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.