在几秒钟内在ImageView上显示大量的位图

时间:2014-09-26 09:34:45

标签: android android-imageview loading bitmapimage

我希望在Android imageview上以5秒(30fps)显示大约150帧。所有帧都存储在SdCard中,我加载到Bitmap Arraylist中。 对于前者 iToD位图的Arraylist mBitmap(位图对象)

for (int i=0;i<100;i++){
    mBitmap = iToD.get( i );    
    mImageView.setImageBitmap(mBitmap);
}

但它不能渲染我想要的所有帧应该能够渲染所有帧。给我一些滑动效果。

2 个答案:

答案 0 :(得分:0)

你必须使用一个处理程序。

final int index = 0;
final Handler handler = new Handler();
Runnable runnable = new Runnable() {

    public void run() {

        mImageView.setImageBitmap(iToD.get( index++ ));
        if(index != iToD.size()) {
        handler.post(this);

    }

};
handler.post(runnable);

答案 1 :(得分:0)

                Hi,

                Try this

                    AnimationDrawable animDrawable = new AnimationDrawable();


               // Create as many drawable as needed and add it to the AnimationDrawable.

                for (int i=0;i<100;i++){
                    mBitmap = iToD.get( i );    
                   Drawable frame = new BitmapDrawable(b1);
                    animDrawable.addFrame(frame, 250);
                }

        //Then create an ImageView and set the background as the animationDrawable.
        mImageView.setBackgroundDrawable(animDrawable);

    Handler startAnimation = new Handler() {
      public void handleMessage(Message msg) {
        super.handleMessage(msg);
        animDrawable.start();
      }
    };


    //and call the handler as

    Message msg = new Message();
    startAnimation.sendMessage(msg);

For More information refer this link,
http://smartandroidians.blogspot.in/2010/02/animation-through-bitmap.html