I have 2 ImageViews, 1 for Canvas and other for a ImageBackground.
The ImageViews have the size of the screen.
When I touch a Screen I need to redraw the Canvas like the example:
private void reDraw() {
Display display = getWindowManager().getDefaultDisplay();
bmOverlay = Bitmap.createBitmap(display.getWidth(), display.getHeight(), oBitmap.getConfig());
oCanvas = new Canvas(bmOverlay);
//I need to erase this line
oCanvas.drawBitmap(bmpBackGround, new Matrix(), null);
//this code paint some bitmaps on the canvas
for (ColorBall ball : colorballs) {
oCanvas.drawBitmap(ball.getBitmap(), ball.getX(), ball.getY(), null);
}
//set the canvas on the image view
getImageView2().setImageBitmap(bmOverlay);
}
But, on this example I redraw the Bitmap, when I touch the screen. I need to redraw a transparent Canvas because I don´t need to redraw the Bitmap on the background, because the bitmap never change. But if I don´t redraw the bitmap, the background stay black and the bitmap stay on the back. Any help?
Check to make sure the overlay bitmap you've created is actually transparent. Create it with config ARGB_8888 explicitly. http://developer.android.com/reference/android/graphics/Bitmap.Config.html
And you might want to move the creation of the bitmap out of the reDraw method and only create it once instead.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.