ObjectAnimator 不淡入

2024-03-31

我正在尝试使用顺序播放一组动画Animator放。除了 alpha 动画外,一切正常(set1)。它从 0.25f 变为 1,但在整个动画和动画结束时都没有褪色set1动画它从 0.25 变为 1,并且没有考虑到setDuration(因此我没有得到淡入淡出效果)。所以我没有淡入淡出效果...当我自己做这个动画时,淡入淡出效果就在那里...有什么想法吗?

我正在使用精彩的九老机器人 http://nineoldandroids.com/库来实现这一点。

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    final ImageView image = (ImageView) findViewById(R.id.image);
    final AnimatorSet set = new AnimatorSet();
    set.play(ObjectAnimator.ofFloat(image, "translationX", 0, 100).setDuration(3000));

    final AnimatorSet set1 = new AnimatorSet();
    //THIS IS THE PROBLEMATIC ANIMATION!!
    set1.play(ObjectAnimator.ofFloat(image, "alpha", 0.25f, 1).setDuration(3000));

    final AnimatorSet set2 = new AnimatorSet();
    set2.play(ObjectAnimator.ofFloat(image, "translationX", 100, 200).setDuration(3000));

    final AnimatorSet set3 = new AnimatorSet();
    set3.playSequentially(set,set1,set2);
    set3.start();
}   

在开发 4.0+ 时

ObjectAnimator alphaAnimation = ObjectAnimator.ofFloat(image, View.ALPHA, 0,1);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

ObjectAnimator 不淡入 的相关文章

随机推荐