关于super.onBackPressed()动画显示 Android关于super.onBackPressed()动画展示
在android登录程序中,单击右下角的注册按钮以显示注册页面的打开动画,然后在左下角显示一个动画以返回到登录页面按钮。好的,所有这些都可以关于super.onBackPressed()动画显示 Android关于super.onBackPressed()动画展示,android,android-animation,uiviewanimationtransition,Android,Android Animation,Uiviewanimationtransition,在android登录程序中,单击右下角的注册按钮以显示注册页面的打开动画,然后在左下角显示一个动画以返回到登录页面按钮。好的,所有这些都可以 我会单击页面底部的左侧登录按钮,然后会出现一个动画来关闭注册页面,而底部右侧显示的动画会显示登录页面按钮。但是实现存在问题。关闭动画后,显示登录页面的按钮动画无法显示。我想是因为RegisterActivity。超级的。OnBackPressed()我不知道该怎么办。谢谢 源代码: 方法onBackPressed() 这是我从我们的讨论中了解到的:
RegisterActivity。超级的。OnBackPressed()
我不知道该怎么办。谢谢
onBackPressed()
这是我从我们的讨论中了解到的: 1/ 按下“后退”按钮时启动关闭动画,然后立即调用
super.onBackPressed()
,这会使活动完成,任何动画设置都是无用的
所以删除super.onBackPressed()代码>是第一个修复程序
2/
在关闭动画的结束事件中,调用另一个动画BottomFastSignUp
,但再次调用RegisterActivity.super.onBackPressed()代码>。这将使活动完成,动画再次无效
所以要解决这个问题,不要在所有动画完成之前完成活动
有两个选项需要修复:
- 听
BottomFastSignUp
动画结束,然后在那里调用finish
- 将
BottomFastSignUp
移动到LoginActivity
。您可以在LoginActivity
中完成RegisterActivity
,覆盖onActivityReenter
,然后在那里执行BottomFastSignUp
为什么调用RegisterActivity.super.onBackPressed()代码>动画结束?请在调用此方法的地方添加代码,因为在单击登录按钮底部的animateanimatereevealclose()
后,实现了animationBottomFastSignUp()
。最后,super.onBackPressed()
将动画转换回登录页面,但是BottomFastSignUp()
和super.onBackPressed()
似乎有冲突。BottomFastSignUp
方法运行另一个动画,对吗?怎么样mcardviewsregister
view,我看到你隐藏了它,但是它的目的是什么,它有什么内容?隐藏mCardViewRegister
是否也会隐藏BottomFastSignUp
中的动画?。您发布的代码中有许多内容需要澄清,因此发布与主要问题相关的所有内容可以帮助您更快地调查问题BottomFastSignUp()
是一个运行的动画。AnimateRevealClose()
是一个关闭注册页面的动画。因此,请在动画结束时隐藏mCardViewRegister
注册页面。运行显示注册按钮的动画,最后返回登录页面。为了更好地进行分析,看到这里,我将底部注册按钮设置为共享元素,而不是Fab按钮。BottomFastSignIn()
是底部按钮位置的显示动画。动画关闭后,“共享元素”按钮将返回右下角。非常感谢您的解决方案,这似乎是一个很有希望的解决方案。祝您生活愉快。很高兴我能提供帮助
/**
* Close the page animation
*/
public void animateRevealClose() {
int centerX = (mCardViewRegister.getWidth()) / 2;
int centerY = (mToSignUpCardView.getTop() + mToSignUpCardView.getBottom()) / 2;
int startRadius = mCardViewRegister.getHeight();
int endRadius = mToSignUpCardView.getWidth() / 2;
Animator mAnimator = ViewAnimationUtils.createCircularReveal(
mCardViewRegister,
centerX,
centerY,
startRadius,
endRadius);
mAnimator.setDuration(500);
mAnimator.setInterpolator(new AccelerateInterpolator());
mAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
BottomFastSignUp(); //The bottom button displays the animation.
mCardViewRegister.setVisibility(View.INVISIBLE);
super.onAnimationEnd(animation);
RegisterActivity.super.onBackPressed();
}
@Override
public void onAnimationStart(Animator animation) {
super.onAnimationStart(animation);
}
});
mAnimator.start();}
@Override
public void onBackPressed() {
animateRevealClose();
super.onBackPressed();
}