How to increase the rotation speed in android?

2020-02-17 08:55发布

I have an image drawable. i rotating the image like a progress bar.

<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:pivotX="50%" android:pivotY="50%" android:fromDegrees="0"
android:toDegrees="360" android:drawable="@drawable/spinner_white_48" />

i want to increase the rotation speed? for that, What attribute i have to use?

5条回答
太酷不给撩
2楼-- · 2020-02-17 09:14

Setting duration and/or repeat count did not help me with an indeterminate ProgressBar animation. I had to increase the toDegrees to have it make additional loops:

<rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:drawable="@drawable/ic_indeterminate_progress"
    android:duration="1"
    android:fromDegrees="0"
    android:pivotX="50%"
    android:pivotY="50%"
    android:toDegrees="1080" /> <!--1080 is 3 loops instead of 1 in same amt of time-->
查看更多
Luminary・发光体
3楼-- · 2020-02-17 09:14

According to this link:

The rotation speed of the indeterminate progress bar is fixed at one revolution every 4 seconds, changing the duration attribute in the drawable XML has no effect. If you prefer to speed it up, you can change the toDegrees attribute to multiples of 360:

  • 720 makes one turn in 2 seconds
  • 1080 makes one turn in 1.33 seconds
  • 1440 makes one turn in 1 second

In addition, you can just use indeterminateDuration for the ProgressBar.

查看更多
Juvenile、少年°
4楼-- · 2020-02-17 09:20

add in code to progress.xml

 <rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:pivotX="50%"
    android:pivotY="50%"
    android:fromDegrees="0"
    android:toDegrees="1080" /> <!--1080 is 3 loops instead of 1 in same amt of time-->
查看更多
贪生不怕死
5楼-- · 2020-02-17 09:29

Set the duration and repeatCount that you want the animation to run.

查看更多
混吃等死
6楼-- · 2020-02-17 09:29
android:duration="required value in ms"
查看更多
登录 后发表回答