如何提高android中的旋转速度?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3165938/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 08:59:55  来源:igfitidea点击:

How to increase the rotation speed in android?

androidanimationrotation

提问by Praveen

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?

我想提高转速?为此,我必须使用什么属性?

采纳答案by Robby Pond

Set the durationand repeatCountthat you want the animation to run.

设置您希望动画运行的持续时间重复计数

回答by DustinB

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:

设置持续时间和/或重复计数对不确定的 ProgressBar 动画没有帮助。我不得不增加 toDegrees 让它产生额外的循环:

<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-->

回答by android developer

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

不确定进度条的旋转速度固定为每 4 秒旋转一圈,更改 drawable XML 中的持续时间属性无效。如果您希望加快速度,可以将 toDegrees 属性更改为 360 的倍数:

  • 720 2秒转一圈
  • 1080转一圈1.33秒
  • 1440一秒转一圈

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

此外,您可以只对 ProgressBar 使用 indeterminateDuration。

回答by Mr_Moradi

add in code to progress.xml

将代码添加到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-->

回答by Primal Pappachan

android:duration="required value in ms"