[英]Android circle reveal animation not smooth
am creating login and signup in same page with circle reveal animation ,switch the view using a floating action button, it very lag when switching one view to another view, 我在同一页面上用圆圈显示动画创建登录和注册,使用浮动操作按钮切换视图,将一个视图切换到另一视图时非常滞后,
Login page Contain two relative layout and a floating action button one view for login and other for signup when floating action button click view will switch to another ie login to signup and vise versa.. i achieved but it is too lag how can i make it smooth 登录页面包含两个相对布局和一个浮动操作按钮,一个视图用于登录,另一个视图用于注册,当浮动操作按钮单击视图将切换到另一个视图时,即登录到注册,反之亦然。.我实现了,但太滞后了,我该怎么做光滑
in tab(big screen) it works very smoothly(am creating two layout one for mobile and other for tab) can anyone help me.. this is my code.. 在选项卡(大屏幕)中,它工作非常顺利(我为移动设备创建了两个布局,为选项卡创建了另一个布局)任何人都可以帮助我..这是我的代码..
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void viewMenu() {
if (!isOpen) {
// int x = layoutContent.getRight();
// int y = layoutContent.getBottom();
int x = Math.round(fab.getX() + fab.getWidth() / 2);
int y = Math.round(fab.getY() - fab.getHeight());
int startRadius = 0;
int endRadius = (int) Math.hypot(layoutMain.getWidth(), layoutMain.getHeight());
fab.setBackgroundTintList(ColorStateList.valueOf(ResourcesCompat.getColor(getResources(),android.R.color.white,null)));
fab.setImageResource(R.drawable.ic_cross);
Animator anim = ViewAnimationUtils.createCircularReveal(layoutButtons, x, y, startRadius, endRadius);
anim.setInterpolator(new AccelerateDecelerateInterpolator());
layoutButtons.setVisibility(View.VISIBLE);
anim.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animator) {
// fst_view.setVisibility(View.GONE);
}
@Override
public void onAnimationEnd(Animator animator) {
}
@Override
public void onAnimationCancel(Animator animator) {
}
@Override
public void onAnimationRepeat(Animator animator) {
}
});
anim.start();
isOpen = true;
} else {
// int x = layoutButtons.getRight();
// int y = layoutButtons.getBottom();
int x = Math.round(fab.getX() + fab.getWidth() / 2);
int y = Math.round(fab.getY() + fab.getHeight()/2) - toolbar.getHeight();
int startRadius = Math.max(layoutContent.getWidth(), layoutContent.getHeight());
int endRadius = 0;
fab.setBackgroundTintList(ColorStateList.valueOf(ResourcesCompat.getColor(getResources(),R.color.colorAccent,null)));
fab.setImageResource(R.drawable.ic_menu_camera);
// fst_view.setVisibility(View.VISIBLE);
Animator anim = ViewAnimationUtils.createCircularReveal(layoutButtons, x, y, startRadius, endRadius);
anim.setInterpolator(new AccelerateDecelerateInterpolator());
anim.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animator) {
}
@Override
public void onAnimationEnd(Animator animator) {
layoutButtons.setVisibility(View.GONE);
}
@Override
public void onAnimationCancel(Animator animator) {
}
@Override
public void onAnimationRepeat(Animator animator) {
}
});
anim.start();
isOpen = false;
}
}
As far as I can see, you could use FastOutLinearInInterpolator()
instead of AccelerateDecelerateInterpolator()
, and add anim.setDuration()
with animation duration you want. 据我FastOutLinearInInterpolator()
,您可以使用FastOutLinearInInterpolator()
代替AccelerateDecelerateInterpolator()
,并添加anim.setDuration()
和所需的动画持续时间。 And set layoutButtons.setVisibility()
to View.INVISIBLE
like described here in the bottom of the article . 然后将layoutButtons.setVisibility()
设置为View.INVISIBLE
如本文底部所述。
Furthermore, you can rid of from Math.round()
when you calculate view x, y coordinates. 此外,当您计算视图x,y坐标时,可以摆脱Math.round()
。
It worked great for my case. 它对我的情况非常有效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.