Why Bitmap to Base64 String showing black background on webview in android?

The JPEG format does not support alpha transparency, which is why the transparent background becomes black when you convert your original image to JPEG.

Use the PNG format instead:

 map1.compress(Bitmap.CompressFormat.PNG, 100, baos); 

and

String imgTag = "<img src="data:image/png;base64," + imgToString               
    + "" align='left' bgcolor="ff0000"/>";   

Leave a Comment