Q:

Optimizations of custom ImageView that frequently refreshes by calling onDraw

I have created a custom ImageView and in its onDraw method I need to draw some bitmaps based on user interaction like touch. Everything is working fine however slowly as I start adding more and more bitmap the application really slows down.
This is what I do in my onDraw of the Custom ImageView
@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    Log.e(TAG, "onDraw called");

    for (int i=0; i < bitmapList.size(); i++){
        drawBitmap(canvas, bitmapList.get(i));
    }
}

As you can see, I am redrawing all the bitmaps in the List everytime onDraw is called naturally when the number of bitmap exceeds say 4-5 the operation becomes very expensive and slows the application down.
Any solution to this proble as to how can this be optimized?

Can calling drawBitmap in a different thread make the operation less expensive?
Is there a way to keep a copy of the previous canvas and then simply restore it in onDraw rather than drawing all the bitmaps again?
The question essentially is refreshing the View with lots of dynamic images on it and its optimization. 

A:

You should create a Bitmap which size must be equal to the ImageView's image size and draw all the bitmaps from the bitmapList on this bitmap only once. On every onDraw() call you should draw only this bitmap. When the bitmapList changes, this additional bitmap must be recreated.

