[英]AnimatedVectorDrawable - reset() is not working properly on some Huawei devices
We use AnimatedVectorDrawable.reset()
to reset the animation to its initial state.我们使用AnimatedVectorDrawable.reset()
将动画重置为其初始状态。 This works well on most of the devices.这适用于大多数设备。 While testing we noticed that on some Huawei devices when reset()
is called the animation starts running.在测试时我们注意到在一些华为设备上调用reset()
时动画开始运行。
Reproduced on these Huawei devices:在这些华为设备上转载:
Any ideas what can I do to fix the problem?任何想法我能做些什么来解决这个问题?
To fix the problem I updated the animation to end in the state it starts.为了解决这个问题,我更新了动画以在它开始的状态下结束。 This allowed me to stop using AnimatedVectorDrawable.reset()
.这让我可以停止使用AnimatedVectorDrawable.reset()
。
Section "Stale state" from this article helped me resolve the problem.从部分“陈旧状态” 这篇文章帮我解决这个问题。 Here is the important part of the section:这是该部分的重要部分:
On older devices I found that their 'state' wasn't being reset (to how it was defined in the VectorDrawable) on each loop.在较旧的设备上,我发现它们的“状态”在每个循环中都没有被重置(在 VectorDrawable 中是如何定义的)。 ... To fix this I added a zero length animation to set properties to their expected value at the start of each loop so that they're ready to be animated eg: ...为了解决这个问题,我添加了一个零长度动画,以便在每个循环开始时将属性设置为其预期值,以便它们准备好进行动画处理,例如:
<set>
<objectAnimator
android:propertyName="fillAlpha"
android:valueFrom="0"
android:valueTo="0"
android:duration="0" />
<objectAnimator
android:propertyName="fillAlpha"
android:valueFrom="0"
android:valueTo="1"
android:startOffset="1900"
android:duration="60"
android:interpolator="@android:interpolator/linear" />
</set>
This is the part that resets the animation to its initial state:这是将动画重置为其初始状态的部分:
<objectAnimator
android:propertyName="fillAlpha"
android:valueFrom="0"
android:valueTo="0"
android:duration="0" />
valueFrom
and valueTo
are equal to valueFrom
in the second objectAnimator
. valueFrom
和valueTo
等于valueFrom
在第二objectAnimator
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.