Reputation: 2059
I want to built a splashscreen for android, where the logo is animated two times:
The first thing works well:
Animation animLeft2Center = AnimationUtils.loadAnimation(this, R.anim.translate_left_to_center);
mLogo.startAnimation(animLeft2Center);
But I don't get the second animation to work.
Animation animCenter2Right = AnimationUtils.loadAnimation(this, R.anim.translate_center_to_right);
mLogo.startAnimation(animCenter2Right);
How can I set a delay of 1 second between both and then start the second animation?
I couldn't find something like setStartDelay
and also it does not fire both animations after each other.
Upvotes: 4
Views: 768
Reputation: 2017
Try to do it in this way:
Animation animLeft2Center = AnimationUtils.loadAnimation(this, R.anim.translate_left_to_center);
mLogo.startAnimation(animLeft2Center);
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
//Do something after 1 second
Animation animCenter2Right = AnimationUtils.loadAnimation(this, R.anim.translate_center_to_right);
mLogo.startAnimation(animCenter2Right);
}
}, 1000);
Upvotes: 4