我想將我的徽標設置爲在啓動應用程序時出現在中間位置。 然後它會移動到頂部,當動畫結束時,字段和按鈕(電子郵件,密碼,登錄按鈕)將出現。執行動畫,然後在動畫完成後顯示字段Android
像Facebook的Android應用程序條目。
我想將我的徽標設置爲在啓動應用程序時出現在中間位置。 然後它會移動到頂部,當動畫結束時,字段和按鈕(電子郵件,密碼,登錄按鈕)將出現。執行動畫,然後在動畫完成後顯示字段Android
像Facebook的Android應用程序條目。
你可以連續動畫編程由animationSet的手段,然後通過AnimationListeners的方式添加任何你想要的結尾。
AnimationSet animationSet= new AnimationSet();
TranslateAnimation a = new TranslateAnimation(
Animation.ABSOLUTE,FROM_X, Animation.ABSOLUTE,FROM_Y,
Animation.ABSOLUTE,TO_X, Animation.ABSOLUTE,TO_Y);
a.setDuration(DURATION);
a.setFillAfter(true);
animationSet.addAnimation(a);
TranslateAnimation b = new TranslateAnimation(
Animation.ABSOLUTE,TO_X, Animation.ABSOLUTE,TO_Y,
Animation.ABSOLUTE,TO_X2, Animation.ABSOLUTE,TO_Y2);
b.setDuration(DURATION2);
b.setFillAfter(true);
b.setStartOffset(DURATION);
animationSet.addAnimation(b);
//add all the animations that you need, having everyone starting in the position and the time where the last one ends.
//Then add a listener to last animation, or to the animationset and write the code you need to run when everything is finished in the onAnimationEnd function
animationSet.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationEnd(Animation animation) {
//code to run when the animations are finished
//for instance, if you have some views in your layout that where hidden
View v= findViewById(R.id.YOUR_HIDDEN_VIEW;
v.setVisibility(View.VISIBLE);
}
});
如果你不知道如何開始的動畫,你havr給你打電話想動畫視圖的startAnimation方法。
THE_LOGO.startAnimation(animationSet);
更新
在你編輯的問題,我可以看到,你只需要一個tranlation。所以它更容易。無論如何,你仍然可以使用動畫組,因爲第一個動畫可能是淡入淡出的alpha動畫。看看這裏http://developer.android.com/reference/android/view/animation/package-summary.html
使用animation listeneronAnimationEnd
的posibilities的AnimationListener添加到您的動畫對象像下面
animation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
//The Function which you want to do before the animation starts
}
@Override
public void onAnimationRepeat(Animation animation) {
//Functions to be executed each repeat of the animation
}
@Override
public void onAnimationEnd(Animation animation) {
//Functions to be executed at the end of animation
}
})
你能爲我提供使用的個例? – Oussa
你需要提供你必須從頭開始的代碼 –