大家好 我要圖像說image1和image2 我想在計時器上顯示兩個圖像,一次只能看到一個圖像。兩個圖像都重疊,意味着image1在image2上方。如何用計時器更改圖像
所以,如果我使用計時器,我希望能夠一次顯示一個圖像。 我該怎麼做。 我希望我清楚我的問題
大家好 我要圖像說image1和image2 我想在計時器上顯示兩個圖像,一次只能看到一個圖像。兩個圖像都重疊,意味着image1在image2上方。如何用計時器更改圖像
所以,如果我使用計時器,我希望能夠一次顯示一個圖像。 我該怎麼做。 我希望我清楚我的問題
將您的圖像放入可繪製文件夾。並創建繪製文件夾中的文件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();
如果動畫未啓動,請在onWindowFocusChanged()事件中啓動動畫 – 2010-08-05 04:19:43
感謝您的回覆.. 是不是需要將xml命名爲「splash.xml」? 其次,如果我將xml名稱更改爲某些xyz amd將此xml添加到anim文件夾,那麼它會工作嗎? 問候 – iscavengers 2010-08-03 10:18:58
是的,你可以設置任何名稱。但你不能把它放在anim文件夾中。 – 2010-08-03 10:26:02
但我沒有得到1點dis是我的oncreate如何看起來像現在。 setContentView(R.layout.main); \t setContentView(R.layout.spl); \t final ImageView splashImage =(ImageView)findViewById(R.id.majicImgView); \t splashImage.setBackgroundResource(R.drawable.magic_number_white); AnimationDrawable splashAnimation =(AnimationDrawable)splashImage.getBackground(); splashAnimation.start(); 是否有可能hv 2 setContentView? – iscavengers 2010-08-03 11:07:50