2012-09-10 69 views
5

我有幾個圖像的標誌,我想在我的閃屏上顯示一個完整的標誌,就像puzzle.How我可以做到這一點。如何在啓動畫面上顯示不同圖像的動畫android

我第一次使用它。任何人都可以幫助我。

三江源

+1

http://developer.android.com/reference/android/graphics/drawable /AnimationDrawable.html轉到此鏈接並閱讀關於逐幀動畫,您可以實現此目的。 –

+3

http://manisivapuram.blogspot.in/2011/06/slideshow-of-images-using-android.html –

回答

1
package com.techipost.imageslider; 

import android.app.Activity; 
import android.os.Bundle; 
import android.view.*; 
import android.view.animation.Animation; 
import android.view.animation.AnimationUtils; 
import android.widget.ImageView; 
import android.os.Handler; 
import java.util.Timer; 
import java.util.TimerTask; 
import com.techipost.imageslider.R; 

public class SliderActivity extends Activity { 

    public int currentimageindex=0; 
    Timer timer; 
    TimerTask task; 
    ImageView slidingimage; 

    private int[] IMAGE_IDS = { 
      R.drawable.splash0, R.drawable.splash1, R.drawable.splash2, 
      R.drawable.splash3 
     }; 

    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.mygame); 
     final Handler mHandler = new Handler(); 

     // Create runnable for posting 
     final Runnable mUpdateResults = new Runnable() { 
      public void run() { 

       AnimateandSlideShow(); 

      } 
     }; 

     int delay = 1000; // delay for 1 sec. 

     int period = 8000; // repeat every 4 sec. 

     Timer timer = new Timer(); 

     timer.scheduleAtFixedRate(new TimerTask() { 

     public void run() { 

      mHandler.post(mUpdateResults); 

     } 

     }, delay, period); 



    } 

    public void onClick(View v) { 

     finish(); 
     android.os.Process.killProcess(android.os.Process.myPid()); 
     } 

    /** 
    * Helper method to start the animation on the splash screen 
    */ 
    private void AnimateandSlideShow() {   

     slidingimage = (ImageView)findViewById(R.id.ImageView3_Left); 
     slidingimage.setImageResource(IMAGE_IDS[currentimageindex%IMAGE_IDS.length]); 

     currentimageindex++; 

     Animation rotateimage = AnimationUtils.loadAnimation(this, R.anim.custom_anim); 

     // slidingimage.startAnimation(rotateimage);    

    }  


} 
+0

其實我已經把我的圖像放在一個數組中,它的60個圖像的標誌,我想顯示它一個通過一個在1秒的間隔 –

+0

一個再見一個圖像完成圖像視圖中的標誌..所以這是可能的,請幫助我我已經嘗試了很多,但沒有得到正確的解決方案 –

+0

不,我無法......我沒有聊天所需的最少20分。 –

0

試試這個方法並保持AnimateandSlideShow()函數相同

new CountDownTimer(1000,60000) { 
       // 1000(1 sec interval time) 
       // 250 (0.25 sec) 
     @Override 
     public void onTick(long millisUntilFinished) { 
      // TODO Auto-generated method stub 

      AnimateandSlideShow(); 

     } 

     @Override 
     public void onFinish() { 
      // TODO Auto-generated method stub 

      // Call NextActivity 

      Intent intent = new Intent(this,NewActivityName.class); 
      intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
      startActivity(intent); 
     } 
    }.start(); 
+0

你如何嘗試? – moDev