我正在開發android應用程序。當第一個動畫正在進行時,我需要開始第二個動畫。如何在Android應用程序中一個接一個地移動圖像?
我需要在一段時間後逐一移動圖像。我在main.xml中使用了兩個imageViews的framelayout。
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView android:src="@drawable/ars1"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/imageView2">
</ImageView>
<ImageView android:src="@drawable/ars"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/imageView1">
</ImageView>
</FrameLayout>
下面是我的animation.xml:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator">
<translate android:fromXDelta="100%p" android:toXDelta="-100%p"
android:duration="1500" />
</set>
在我的活動類的onCreate方法
,我在做類似下面這是行不通的。
ImageView imageView1;
ImageView imageView2;
Animation tranOut;
tranOut = AnimationUtils.loadAnimation(this, R.anim.animation);
imageView1 = (ImageView)findViewById(R.id.imageView1);
imageView1.setAnimation(tranOut);
imageView2 = (ImageView)findViewById(R.id.imageView2);
imageView2.setAnimation(tranOut);
請告訴我如何一個接一個地移動這兩個圖像。
由於 喬蒂
感謝您的回覆。但是當第一個圖像移動時,我必須開始第二個圖像。所以我需要在第一個圖像的動畫開始時,而不是在第一個動畫結束時開始第二個圖像的動畫。請看看你能否幫忙。 – Jyoti