Ihor DIM
Ihor DIM

Reputation: 689

Android Canvas background

There are a lot of small images in background of my view. And position of each image depends on screen resolution. Also there are other objects that dynamically redraws after onToch ivent. It works fine without background but when i try to draw it in onDraw() i get KeyDispatchingTimedOut error. How can i compose a backgrount in a single bitmap when my app first starts, or there are other better solutions?

Upvotes: 0

Views: 8253

Answers (1)

DKIT
DKIT

Reputation: 3481

Bitmap background = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_4444);
Canvas canvas = new Canvas(background);
canvas.draw(yourSmallImage, posX, posY, null);
....
c.drawBitmap(background, 0, 0, null);

This will use 'background' as a scratchpad, then write the completed background image to the current canvas when you are done 'scratching' :-)

Upvotes: 1

Related Questions