我使用ZBarSDK来做一个二维码扫描的app,然后用SurfaceView来展示。我在此的基础上还打算添加一个扫描框,类似微信那样。结果我添加TranslateAnimation之后发现动画很卡。请问这是什么问题呢?scanLine.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override
public void onGlobalLayout() {
Logger.i(CameraOverlay.class, "addOnGlobalLayoutListener");
scanLine.setDrawingCacheEnabled(true);
scanLine.clearAnimation();
scanLine.setAnimation(null);
TranslateAnimation animation = new TranslateAnimation(0, scanRect.width() - 10, 0, 0);
animation.setRepeatCount(-1);
animation.setDuration(2600);
scanLine.startAnimation(animation);
}
});
animationcamera性能
public void onGlobalLayout() {
Logger.i(CameraOverlay.class, "addOnGlobalLayoutListener");
scanLine.setDrawingCacheEnabled(true);
scanLine.clearAnimation();
scanLine.setAnimation(null);
TranslateAnimation animation = new TranslateAnimation(0, scanRect.width() - 10, 0, 0);
animation.setRepeatCount(-1);
animation.setDuration(2600);
scanLine.startAnimation(animation);
}
});
animationcamera性能
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货