Let's say i have the following code:
img1.animate().alpha(.5f).setDuration(300);
And I want to execute this whenever the animation is over
img1.setImageReasource(R.drawble.img_guitar);
How do I do that??
Let's say i have the following code:
img1.animate().alpha(.5f).setDuration(300);
And I want to execute this whenever the animation is over
img1.setImageReasource(R.drawble.img_guitar);
How do I do that??
You can add a listener to your animation:
imageView.animate().setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
imageView.setImageResource(R.drawable.img_guitar);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
You can also use withActionEnd(Runnable)
:
imageView.animate().withEndAction(new Runnable() {
@Override
public void run() {
imageView.setImageResource(R.drawable.img_guitar);
}
})