[英]how to change images with timer
大家好我有圖像說image1和image2我想在計時器上顯示兩個圖像,一次只能看到一個圖像。 兩個圖像都是重疊的,這意味着,image1在image2上。
所以,如果我使用計時器,我希望能夠一次顯示一個圖像。 我該怎么做呢。 我希望我對自己的問題很清楚
將您的圖像放在Drawable文件夾中。 並在drawable文件夾中創建一個splash.xml文件,如下所示:
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="true"> <item android:drawable="@drawable/splash_1" android:duration="200" /> <item android:drawable="@drawable/splash_2" android:duration="200" /> <item android:drawable="@drawable/splash_3" android:duration="200" /> <item android:drawable="@drawable/splash_4" android:duration="200" /> <item android:drawable="@drawable/splash_5" android:duration="200" /> </animation-list>
在你的活動課上
setContentView(R.layout.splashscreen);
final ImageView splashImage = (ImageView) findViewById(R.splash.ImageView);
splashImage.setBackgroundResource(R.drawable.splash);
splashAnimation = (AnimationDrawable) splashImage.getBackground();
splashAnimation.start();
代碼不會從第一個圖像更改為下一個圖像。
這段代碼有什么問題嗎?
final ImageView splashImage = (ImageView) findViewById(R.id.ImageView01);
splashImage.setBackgroundResource(R.drawable.splash);
AnimationDrawable splashAnimation = (AnimationDrawable) splashImage.getBackground();
splashAnimation.start();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.