【发布时间】:2014-05-17 21:03:39
【问题描述】:
当我的一个进程在后台工作时,我一直在尝试实现一个简单的动画。
动画的要求是围绕屏幕中心的圆形图像视图创建波纹效果。
当个人资料圈周围有一些不断增长的圈子动画时,可以在 Google 环聊视频会话中看到示例,或者在搜索个人资料的 Tinder 等应用程序中。
我试图将大约 4 个可绘制的圆圈放在另一个上,并在 for 循环中改变它们的可见性:
ImageView one = (ImageView) rootView.findViewById(R.id.imageView1);
ImageView two = (ImageView) rootView.findViewById(R.id.imageView2);
ImageView three = (ImageView) rootView.findViewById(R.id.imageView3);
ImageView four = (ImageView) rootView.findViewById(R.id.imageView4);
try {
for(int i=1; i<10; i++){
one.setVisibility(one.VISIBLE);
Thread.sleep(1000);
two.setVisibility(two.VISIBLE);
Thread.sleep(1000);
three.setVisibility(three.VISIBLE);
Thread.sleep(1000);
four.setVisibility(four.VISIBLE);
Thread.sleep(1000);
one.setVisibility(one.INVISIBLE);
Thread.sleep(1000);
two.setVisibility(two.INVISIBLE);
Thread.sleep(1000);
three.setVisibility(three.INVISIBLE);
Thread.sleep(1000);
four.setVisibility(four.INVISIBLE);
Thread.sleep(1000);
}
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
但是当我运行它时,应用程序崩溃了。有没有更好的方法来做到这一点?
提前致谢。
【问题讨论】: