是否有一種簡單的方法來爲視圖設置動畫效果,以便一個接一個地動畫。在視圖上應用動畫序列
我想這:
button.animate().translationX(500).setDuration(300);
button.animate().translationX(0).setDuration(300).setStartDelay(2000);
是否有一種簡單的方法來爲視圖設置動畫效果,以便一個接一個地動畫。在視圖上應用動畫序列
我想這:
button.animate().translationX(500).setDuration(300);
button.animate().translationX(0).setDuration(300).setStartDelay(2000);
事情是這樣的:
button.animate().translationX(500).setDuration(300).withEndAction(new Runnable() {
@Override
public void run() {
button.animate().translationX(0).setDuration(300).start();
}
}).start();
謝謝,它工作 –
嘗試的第一個動畫設置一個偵聽器,以便當它結束時,你就可以開始第二動畫:
button.animate().translationX(500).setDuration(300).setListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
button.animate().translationX(0).setDuration(300).start();
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
謝謝你的回答,但我發現Vitaly Zinchenko回答更簡單 –
它更簡單,但它也需要API級別16工作,而AnimatorListener只需要API級別12. –
您可以指定動畫集,然後將其應用於視圖。請參閱http://developer.android.com/reference/android/view/anim ation/AnimationSet.html –