我試圖在活動之間顯示啓動畫面。爲此,我使用加載ImageView的處理程序,然後在一段時間後將可見性設置爲GONE。用動畫加載屏幕後刪除圖像,Android
我想使它更加花哨,並使用loadAnimation爲其設置動畫效果。我遇到的問題是一旦處理程序結束了動畫停止,但不會從屏幕上刪除加載圖像。相反,它只是作爲整個活動的背景。
我想知道如何刪除處理程序停止後的飛濺圖像。
下面是我的代碼:
private static final long SPLASHTIME = 3000;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main)
ImageView splash = (ImageView)findViewById(R.id.splashscreen);
final Animation a = AnimationUtils.loadAnimation(getBaseContext(),R.anim.progress_anim);
a.setDuration(1000);
splash.startAnimation(a);
new Handler().postDelayed(new Runnable(){
@Override
public void run() {
a.cancel();
splash.setVisibility(View.GONE);
}
}, SPLASHTIME);
}
XML飛濺的形象:
<ImageView
android:id="@+id/splashscreen"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="@drawable/loading_circle"
android:layout_gravity="center"
/>
在xml中移除圖像並在oncreate中設置該圖像。 – 2013-05-10 04:51:06