每10秒的Android更改图片 [英] Android Change picture every 10 seconds
问题描述
我试着去写一个非常基本的Android应用程序,显示大约5图片一前一后相互在屏幕上。我想这大约10秒后,显示不同的画面。谁能告诉我,我怎么会去解决这个问题。下面我介绍了我会期待的。
Im trying to write a very basic android app that displays around 5 pictures one after each other on the screen. I want it to display a different picture after about 10 seconds. Can anyone advise me on how I would go around this. Below i have outlined what i would be looking for.
照片1
图2
图3
图4
图5
Picture 1
Picture 2
Picture 3
Picture 4
Picture 5
显示全屏图片1
等待10秒
删除照片1和显示图片2
等待10秒钟
删除图片2和显示图片3
等待10秒钟
删除图片3和显示图片4
等待10秒钟
删除图片4和显示图片5
等待10秒钟
display full screen Picture 1
wait 10 seconds
Remove Picture 1 and Display Picture 2
Wait 10 seconds
Remove Picture 2 and Display Picture 3
Wait 10 seconds
Remove Picture 3 and Display Picture 4
Wait 10 seconds
Remove Picture 4 and Display Picture 5
Wait 10 seconds
再次启动
推荐答案
你有没有考虑过使用的帧动画?
Have you considered using Frame Animations?
您可以在包含一帧一帧动画的动画文件夹指定XML,specifing每个图像的持续时间和其他设置,检查出来
You can specify an xml in your anim folder that contains a frame-by-frame animation, specifing each image duration, and other settings, check it out
更新
您也可以通过编程建立帧动画:
You can also build a frame animation programmatically of course:
AnimationDrawable animation = new AnimationDrawable();
animation.addFrame(getResources().getDrawable(R.drawable.image1), 100);
animation.addFrame(getResources().getDrawable(R.drawable.image2), 500);
animation.addFrame(getResources().getDrawable(R.drawable.image3), 300);
animation.setOneShot(false);
ImageView imageAnim = (ImageView) findViewById(R.id.img);
imageAnim.setBackgroundDrawable(animation);
// start the animation!
animation.start()
这篇关于每10秒的Android更改图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!