gpt4 book ai didi

Android 如何在多个动画上添加一些延迟?

转载 作者:太空宇宙 更新时间:2023-11-03 11:20:28 25 4
gpt4 key购买 nike

我想要的是下面代码中的每个动画都以延迟开始,就像一个序列。所以我有这段代码:

   public void setAnimation(){
View view;
String animation = prefs.getString("animations", "Scale");
String interpolator = prefs.getString("interpolators", "Bounce");
Animation animate = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.scale_in);
for(int i=0; i<gridView.getChildCount(); i++){
view = gridView.getChildAt(i);

view.startAnimation(animate);
}
}

因为有一个for循环,所以所有的子动画都会立即开始。我已经尝试过:

Thread.sleep....
Handler...
animate.setStartTime...
animate.setStartOffset...

但是所有的子动画都是立即开始的。

我在循环中试过这个方法,动画不会启动:

animate.setAnimationListener(new AnimationListener(){
public void onAnimationEnd(Animation arg0) {
view.startAnimation(animate);
}

public void onAnimationRepeat(Animation arg0) {
}

public void onAnimationStart(Animation arg0) {
}

});

提前致谢。

最佳答案

解决方案是创建一个 GridLayoutAnimationController 或 LayoutAnimationController。

关于Android 如何在多个动画上添加一些延迟?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9341447/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com