ObjectAnimator不淡入 [英] ObjectAnimator not fading in
问题描述
我正在尝试使用Animator
集顺序播放一组动画.除了alpha动画(set1
)之外,其他所有东西都在工作.它从0.25f更改为1,但在整个动画中并没有褪色,并且在set1
动画结束时,它从0.25更改为1,并且没有考虑setDuration
(因此我没有得到渐隐效果).所以我没有淡入淡出的效果...当我自己制作动画时,淡入淡出的效果是....有什么想法吗?
I am trying to play a set of animations sequentially using the Animator
set. Everything is working except for the alpha animation(set1
). It is changing from 0.25f to 1 but it is not fading throughout the animation and at the end of the set1
animation it is changing from 0.25 to 1 and not taking in consideration the setDuration
(as a result I am not getting the fade in effect). So I don't have the fade in effect... When I do this animation by itself the fade in effect is there....Any ideas?
我正在使用很棒的 nineoldandroids 库来实现此功能.
I am using the wonderful nineoldandroids library to implement this.
@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以上版本上运行
While working on 4.0+
ObjectAnimator alphaAnimation = ObjectAnimator.ofFloat(image, View.ALPHA, 0,1);
这篇关于ObjectAnimator不淡入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!