Reputation: 1051
I am wondering why in the code below my button giftFinal does not get his alpha back. After execution the button text is not visible. Not even the text color or backgroundcolor are set:
final float alpha=giftFinal.getAlpha();
Animation fadeOut = new AlphaAnimation(1, 0);
fadeOut.setStartOffset(30000);
fadeOut.setDuration(2000);
fadeOut.setFillAfter(true);
fadeOut.setAnimationListener(new AnimationListener(){
@Override
public void onAnimationEnd(Animation animation) {
if(help!=null) {
//palce old help text back again
giftFinal.setText(help);
giftFinal.setTextColor(Color.BLACK);
giftFinal.setBackgroundColor(Color.WHITE);
giftFinal.setAlpha(alpha);
giftFinal.setVisibility(View.VISIBLE);
}
}
@Override
public void onAnimationRepeat(Animation animation) {}
@Override
public void onAnimationStart(Animation animation) {}
});
giftFinal.startAnimation(fadeOut);
Upvotes: 0
Views: 247
Reputation: 2737
This is because you have set setFillAfter as true. According to the documentation, "If fillAfter is true, the transformation that this animation performed will persist when it is finished. Defaults to false if not set." So remove fadeOut.setFillAfter(true)
or change it to fadeOut.setFillAfter(false)
.
Upvotes: 1