[英]Android change alpha on Translate animation
My translate Animation work fine and i would like to change widget alpha During animation, for example i want to set alpha 1.0
to 0.0
when translate animation move my widget to bottom, this is my code but change alpha dont work correctly 我的翻译动画工作正常,我想更改小部件的alpha,例如,在动画过程中,我想将翻译动画将小部件移到底部时将alpha 1.0
设置为0.0
,这是我的代码,但是更改alpha不能正常工作
public void SlideToAbove() {
Animation slide = null;
slide = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f,
Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF,
0.0f, Animation.RELATIVE_TO_SELF, 0.2f);
AnimationSet set = new AnimationSet(true);
slide.setDuration(6000);
set.addAnimation(slide);
Animation anim = new AlphaAnimation(1.0f, 0.0f);
anim.setDuration(100);
set.addAnimation(anim);
slide.setDuration(1500);
slide.setFillAfter(true);
slide.setFillEnabled(true);
arrow.startAnimation(slide);
slide.setRepeatCount(Animation.INFINITE);
slide.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
arrow.clearAnimation();
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
arrow.getWidth(), arrow.getHeight());
lp.addRule(RelativeLayout.ALIGN_PARENT_TOP);
arrow.setLayoutParams(lp);
}
});
}
The reason is that you don't use your Alpha animation at all. 原因是您根本不使用Alpha动画。
You add it to the set: 您将其添加到集合中:
set.addAnimation(anim);
and don't use that set, but use only slide
animation 并且不使用该集合,而仅使用slide
动画
arrow.startAnimation(slide);
instead. 代替。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.