繁体   English   中英

使用动画制作闪光效果

[英]Using an animator to create a flashing effect

所以我有这段代码:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">

        <objectAnimator
            android:propertyName="backgroundColor"
            android:duration="100"
            android:repeatCount="-1"
            android:repeatMode="reverse"
            android:valueFrom="@color/light_blue"
            android:valueTo="@color/blue"/>

</set>

我在像这样的ImageButton上运行它。

AnimatorSet set = (AnimatorSet) AnimatorInflater.loadAnimator(appContext,
                R.animator.invitation_animator);
            set.setTarget(actionInvitation);
            set.start();

我希望它再次从浅蓝色闪烁到蓝色,但是相反,它在颜色之间逐渐消失。 我正在使用此动画作为用户收到邀请时的通知,这就是为什么我想要闪烁的效果。

有谁知道我怎么能做到这一点?

您需要缩短动画的持续时间。 最好的方法是首先尝试:

android:duration="50"

然后,如果您需要更小的间隙,则减少一半:

android:duration="25"

或增加速度太快:

android:duration="75"

等等,直到获得想要的效果。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM