Closed DanteAndroid closed 6 years ago
Hi @DanteAndroid!
It isn't in the wiki, but you simply add in xml with:
android:background="@color/your_color_resource"
or with Java code:
drawView.setBackgroundResource(R.color.you_color_resource);
I have tried that method. But it only adds background when you draw, not in the actual bitmap.(When I save it, its background is black)
Was this fixed? Can you now add a background that you can draw on top of ? Also is there a way to add a bitmap as the background?
Ok, I actually working on that...
Okay. Thanks.
@DanteAndroid, @jd-alexander... Can you please check the new update? 1.2.6 and comment for close this "issue"
Regards!
@ByoxCode Sorry to say that this problem still exists in 1.2.6(background is black).
@DanteAndroid the current version is 1.2.11, can you check this version please... I know what is the problem, but I can't remember if in this version doesn't has this error
@ByoxCode I don't know if I use it wrong, but the background is still black in 1.2.11
@DanteAndroid can you explain more detailed your problem, maybe I have a bad idea of this.
Without android:background="@color/your_color_resource"
or with it, I have a black background after save the draw in drawview to file.
Code here: https://github.com/DanteAndroid/TimePill/blob/master/app/src/main/java/com/dante/diary/draw/DrawActivity.java#L218 XML here: https://github.com/DanteAndroid/TimePill/blob/master/app/src/main/res/layout/fragment_draw.xml#L25
There is one way to change the background color of an image.
First Solution:
Programmatically change each pixel from transparent to white(or any color). Add this code when you capture bitmap while saving.
Code here:
int width = bitmap.getWidth();
int height = bitmap.getHeight();
for(int x = 0; x < width; x++) {
for(int y = 0; y < height; y++) {
if(bitmap.getPixel(x, y) == Color.TRANSPARENT) {
bitmap.setPixel(x, y, Color.WHITE);
}
}
}
Maybe this is because the image that you are trying to save is a PNG format, if you see in a gallery app the transparent background will be rendered in black color but is the background of the app.
How to add a white board background? Default the background is transparent.