问题描述
我想更改默认的动画进度
,所以我在我的主题添加自定义样式:
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>
我打电话这种风格在我的进度
为以下内容:
<ProgressBar
android:id="@+id/loadingProgressBar"
style="@style/ProgressTheme"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
问题出在 spinner_holo_light.xml
:
如果我用下面的,一切工作正常与OS 3.0+设备,但进度不旋转在旧版本的操作系统:
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" />
但是,如果我用动画,旋转
相反,动漫作品的每一个操作系统版本,但结果是非常laggy动画。
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?
推荐答案
在旧设备上这是一个问题,当安卓fromDegrees
大于机器人:toDegress
在&LT;转&GT;
。尝试交换的值:
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" />
动画可能是laggy对旧设备。为了解决这个问题添加安卓animationResolution
的风格:
<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>
这篇关于Android的定制进度不旋转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!