如何在两个活动之间使用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