[英]Android frame animation delays the navigation drawer speed
I am using the navigation drawer. 我正在使用导航抽屉。 I want to use a frame animation as background in my main activity with the navigation drawer. 我想在导航抽屉的主要活动中使用框架动画作为背景。 But the navigation drawer opening and closing speed becomes slow when frame animation is started. 但是,当开始帧动画时,导航抽屉的打开和关闭速度会变慢。 So I tried the following: 所以我尝试了以下方法:
@Override
public void onDrawerClosed(View drawerView) {
super.onDrawerClosed(drawerView);
frameAnimation.start();
}
@Override
public void onDrawerOpened(View drawerView) {
frameAnimation.stop();
super.onDrawerOpened(drawerView);
}
This code does the close drawer in a smooth way. 该代码可以平滑地完成关闭抽屉。 But opening still causes some delay. 但是开放仍然会导致一些延迟。 Is there any way to sort it. 有什么办法可以对它进行排序。
Try giving a small delay to the animation stop and start calls. 尝试给动画停止和开始调用稍加延迟。 You can experiment with the delay value. 您可以尝试使用延迟值。 Using 450ms here. 在这里使用450毫秒。
Handler handler = new Handler();
handler.postDelayed(new Runnable(){
public void run(){
frameAnimation.stop();
}
},450);
handler.postDelayed(new Runnable(){
public void run(){
frameAnimation.start();
}
},450);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.