如何在兩個活動之間使用Reveal動畫?有很多關於如何使用它在Activity中啓動視圖的信息和示例,但是我想單擊一個按鈕並啓動一個Reveal Animation來顯示下一個Activity。 我嘗試在第一個佈局中包含第二個佈局並將其設置爲不可見,然後在單擊該按鈕時將其顯示出來。但它不能正常工作。我想知道如果我可以簡單地將Reveal動畫定義爲XML,但我不知道如何去做。 謝謝Android Reveal動畫開始活動
3
A
回答
1
例如,您可以爲活動的父佈局設置動畫。這是一個可以幫助你的答案。它在活動中消失,但如果您瞭解如何完成,則可以應用任何動畫。
Fade In Android Launch Activity
要取消建立在活動動畫的標準,你可以使用這個Intent.FLAG:
intent.setFlag(Intent.FLAG_ACTIVITY_NO_ANIMATION);
當您啓動活動。
1
顯示效果成功爲我在活動和片段上工作 應用下面的代碼來設置對活動或片段的顯示效果。刪除註釋以使用以下代碼中的特定動畫表單。
- >的setContentView
後使用此代碼 rootview = (RelativeLayout) findViewById(R.id.rootview);
rootview.setBackgroundColor(getResources().getColor(R.color.colorAccent));
rootview.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
v.removeOnLayoutChangeListener(this);
/*//BOTTOM RIGHT TO TOP LEFT ANIMATION
int cx = (framelayout.getLeft() + framelayout.getRight());
int cy = (framelayout.getTop() + framelayout.getBottom());
// get the hypothenuse so the radius is from one corner to the other
int radius = (int) Math.hypot(right, bottom);
Animator reveal = ViewAnimationUtils.createCircularReveal(v, cx, cy, 0, radius);
reveal.setInterpolator(new AccelerateDecelerateInterpolator());
reveal.setDuration(600);
reveal.start();*/
/* //LEFT TOP TO BOTTOM RIGHT ANIMATION
int cx1 = 0;
int cy1 = 0;
// get the hypothenuse so the radius is from one corner to the other
int radius1 = (int) Math.hypot(right, bottom);
Animator reveal1 = ViewAnimationUtils.createCircularReveal(v, cx1, cy1, 0, radius1);
reveal1.setInterpolator(new DecelerateInterpolator(2f));
reveal1.setDuration(1000);
reveal1.start();*/
/* //EFFECT START WITH CENTER
float finalRadius = (float) Math.hypot(v.getWidth(), v.getHeight());
int cx1 = (framelayout.getLeft() + framelayout.getRight())/2;
int cy1 = (framelayout.getTop() + framelayout.getBottom())/2;
Animator anim = ViewAnimationUtils.createCircularReveal(v, cx1, cy1, 0, finalRadius);
anim.setDuration(1000);
anim.setInterpolator(new AccelerateDecelerateInterpolator());
anim.start();*/
//OPEN WITH BOTTOM CENTER
int cx = (rootview.getLeft() + rootview.getRight())/2;
int cy = (rootview.getTop() + rootview.getBottom());
// get the hypothenuse so the radius is from one corner to the other
int radius = (int) Math.hypot(right, bottom);
Animator reveal = ViewAnimationUtils.createCircularReveal(v, cx, cy, 0, radius);
reveal.setInterpolator(new AccelerateDecelerateInterpolator());
reveal.setDuration(350);
reveal.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
// rootview.setBackgroundResource(R.color.white);
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
reveal.start();
}
});
- >要隱藏顯示效果onBackPressed()
// previously visible view
final View myView = findViewById(R.id.rootview);
// get the center for the clipping circle
int cx = myView.getWidth()/2;
int cy = myView.getHeight()/2;
// get the initial radius for the clipping circle
float initialRadius = (float) Math.hypot(cx, cy);
// create the animation (the final radius is zero)
Animator anim =
ViewAnimationUtils.createCircularReveal(myView, cx, cy, initialRadius, 0);
anim.setDuration(50);
// make the view invisible when the animation is done
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
myView.setVisibility(View.INVISIBLE);
}
});
// start the animation
anim.start();
相關問題
- 1. android-開始動畫
- 2. Android開始活動
- 3. 活動開始時的動畫跳轉
- 4. 動畫完成後開始活動
- 5. 使用動畫開始活動
- 6. 如何開始動畫結束活動
- 7. 開始啓動畫面活動
- 8. 如何在Android動畫結束後啓動開始活動
- 9. 安卓動畫開始新的活動或解散活動
- 10. Android動畫開始位置
- 11. android開始活動問題
- 12. android SlidingTab開始活動?
- 13. android開始活動錯誤
- 14. 的Android開始空活動
- 15. Android活動開始崩潰
- 16. Android BroadcastReceiver開始活動
- 17. Android的新活動開始
- 18. Android:誰開始活動
- 19. android更改開始活動
- 20. 無法開始活動 - Android
- 21. Android:從MenuItem開始活動
- 22. 開始活動的Android
- 23. Android:從BroadcastReceiver開始活動
- 24. Android - 開始兩個活動
- 25. 按鈕開始活動Android
- 26. Android開始新的活動
- 27. Android:開始下一個活動之前未完成動畫
- 28. Edge動畫從動畫開始動畫
- 29. 開始活動
- 30. 從開始開始活動
謝謝,那正是我一直在尋找。 – Artist404