1
我嘗試按特定順序淡入按鈕。每次一個按鈕消失,但代碼完成後按鈕會一起褪色。我嘗試在每個淡入淡出順序後使用Thread.sleep,但它根本沒有幫助。有人有想法嗎?android:淡入淡出動畫
代碼:
for(int i=0;i<counter;i++)
{
switch (entered[i]) {
case 1:
ImageView myImageView1= (ImageView)findViewById(R.id.red_button);
Animation myFadeInAnimation1 = AnimationUtils.loadAnimation(this, R.anim.fadein);
myImageView1.startAnimation(myFadeInAnimation1); //Set animation to your ImageView
break;
case 2:
ImageView myImageView2= (ImageView)findViewById(R.id.yellow_button);
Animation myFadeInAnimation2 = AnimationUtils.loadAnimation(this, R.anim.fadein);
myImageView2.startAnimation(myFadeInAnimation2); //Set animation to your ImageView
break;
case 3:
ImageView myImageView3= (ImageView)findViewById(R.id.green_button);
Animation myFadeInAnimation3 = AnimationUtils.loadAnimation(this, R.anim.fadein);
myImageView3.startAnimation(myFadeInAnimation3); //Set animation to your ImageView
break;
case 4:
ImageView myImageView4= (ImageView)findViewById(R.id.blue_button);
Animation myFadeInAnimation4 = AnimationUtils.loadAnimation(this, R.anim.fadein);
myImageView4.startAnimation(myFadeInAnimation4); //Set animation to your ImageView
break;
default:
//finish();
break;
}
try {
Thread.sleep(3000); // one second
}
catch (Exception e) {}
}