Java Android图像视图动画速度较慢
我正在尝试同时为多个图像视图应用多个动画。下面是代码片段Java Android图像视图动画速度较慢,java,android,performance,android-animation,Java,Android,Performance,Android Animation,我正在尝试同时为多个图像视图应用多个动画。下面是代码片段 final AnimatorSet animationSet = new AnimatorSet(); for(int i=0;i<frame.getChildCount();i++){ final ImageView vw = (ImageView) frame.getChildAt(i); animationSet.playToge
final AnimatorSet animationSet = new AnimatorSet();
for(int i=0;i<frame.getChildCount();i++){
final ImageView vw = (ImageView) frame.getChildAt(i);
animationSet.playTogether(
ObjectAnimator.ofFloat(vw, "rotationY", 60),
ObjectAnimator.ofFloat(vw, "scaleY", 0.8f),
ObjectAnimator.ofFloat(vw, "x", 0)
);
animationSet.setDuration(600);
animationSet.setInterpolator(new DecelerateInterpolator(1.5f));
animationSet.start();
final AnimatorSet animationSet=new AnimatorSet();
对于(int i=0;i使用。
这可能是设置视图动画的最简单方法,通常非常平滑。对于您的示例,它可能是这样的:
vw.animate()
.rotationY(60)
.scaleY(0.8f)
.setDuration(600)
.setInterpolator(new DecelerateInterpolator());
private Handler mHandler = new Handler();
for(int i=0;i<frame.getChildCount();i++){
final ImageView vw = (ImageView) frame.getChildAt(i);
mHandler.post(new Runnable() {
@Override
public void run () {
vw.animate()
.rotationY(60)
.scaleY(0.8f)
.setDuration(600)
.setInterpolator(new DecelerateInterpolator());
}
});
}
检查以查找所有可用的方法
编辑:
如果同时有多个动画滞后,请尝试使用一个新的动画,它将为您处理线程,并应使其更平滑。
大概是这样的:
vw.animate()
.rotationY(60)
.scaleY(0.8f)
.setDuration(600)
.setInterpolator(new DecelerateInterpolator());
private Handler mHandler = new Handler();
for(int i=0;i<frame.getChildCount();i++){
final ImageView vw = (ImageView) frame.getChildAt(i);
mHandler.post(new Runnable() {
@Override
public void run () {
vw.animate()
.rotationY(60)
.scaleY(0.8f)
.setDuration(600)
.setInterpolator(new DecelerateInterpolator());
}
});
}
private Handler mHandler=new Handler();
对于(int i=0;i@A亲爱的大鸨-谢谢,这有助于一次动画制作。我正在尝试从右向左滚动图像,或者从右向左滚动图像,滚动将是连续的。在这种情况下,动画非常慢。我还尝试将图像转换为位图并为画布绘制视图设置动画。这也很慢。有什么建议吗。?