9 patch editor android studio suddenly black
Asked Answered
M

2

2

Anyone with experience having the 9 patch editor in AS suddenly start using a black background for images? I have had no problems using it, now suddenly I can't make any edits. The image below should have a transparent background. If I try and drag the stretchable patches nothing changes, it keeps resetting itself, so to speak. Also this change happened in the same session.

9 patch editor going schizo

Manteltree answered 6/8, 2014 at 23:18 Comment(5)
Did you try other nine patches? Do you have that image under version control? May be the image got corrupted somehow. Have you tried opening and fixing the image in another program?Unpen
I've opened other 9 patches and other images all the same issue. I have not done the 9 patch in PS yet, mostly because I just want to know what the deal is with the one in AS.Manteltree
I wonder if it's not Android Studio trying to load the theme that's supposed to be applied to the drawable, or lacking the presence of a theme, just defaulting to a black background for the transparent 9 patch?Unpen
Thats an interesting thought. I'll try loading it without it being referenced. The box above is actually transparent with a 2px boarder. The theme for the layout is a semi-transparent gray.Manteltree
still have not found or seen any resolution for this. i did just start using the separate 9 patch editor which comes bundled in the sdk. some images are loading without the black in AS and some are not. I can't find a common thread between them though. In one case the fb box is a copy of a another box in PS where the only difference is the color the box outline. One is transparent in the editor and one is black.Manteltree
S
1

Question is old, but I have run into this issue 5 minutes ago. The problem occur when I save custom .png in paint.net and choose option for depth color "auto-detection". But when I saved it with with color depth "32 bit" all ok, and background is transparent.

enter image description here

Schleswig answered 20/6, 2018 at 13:54 Comment(0)
R
0

I have the similar problem, right-click to select "Create 9-Patch file...", the transparent area become black. It only occur in some images after converted by ImageMagick.

Check the image details by pngcheck tool:

xb@dnxb:/tmp$ pngcheck msg_box.png #original image
OK: msg_box.png (2251x967, 32-bit RGB+alpha, non-interlaced, 99.9%).

It becomes palette+trns after converted by ImageMagick:

xb@dnxb:/tmp$ convert msg_box.png -transparent white -trim msg_trim.png
xb@dnxb:/tmp$ pngcheck msg_trim.png 
OK: msg_trim.png (394x311, 8-bit palette+trns, non-interlaced, 98.5%).

The solution is prefix the image with png32 to force it outputs RGBA:

xb@dnxb:/tmp$ convert msg_box.png -transparent white -trim png32:msg_trim.png
xb@dnxb:/tmp$ pngcheck msg_trim.png                                                                          
OK: msg_trim.png (394x311, 32-bit RGB+alpha, non-interlaced, 99.4%).                                                                                  
xb@dnxb:/tmp$ 

Now when I paste this image in Android Studio and right-click to select "Create 9-Patch file...", then it able to keep transparent instead of black.

Returnee answered 20/6, 2018 at 11:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.