我如何制作一个例如淡出动画以获取没有父布局的浮动视图。此代码适用于嵌套在布局内的所有内容。是否有选项可以使父母在浮动服务中显示?
代码:
protected void FadeAnimation(View animationview, boolean fadein)
{
if(fadein){
//Fade in Animation
Animation animationFadeIn = AnimationUtils.loadAnimation(this, R.anim.introfadein);
animationFadeIn.setFillAfter(true);
animationFadeIn.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
animationview.setVisibility(View.VISIBLE);
}
@Override
public void onAnimationEnd(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
animationview.setAnimation(animationFadeIn);
} else {
//Fade out Animation
Animation animationFadeOut = AnimationUtils.loadAnimation(this, R.anim.introfadeout);
animationFadeOut.setFillAfter(true);
animationFadeOut.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
animationview.setVisibility(View.GONE);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
animationview.setAnimation(animationFadeOut);
}
}
感谢您的帮助! :)