9 patch editor android studio suddenly black

旧时模样 提交于 2020-01-02 10:36:30

问题


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.


回答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.




回答2:


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.



来源:https://stackoverflow.com/questions/25171838/9-patch-editor-android-studio-suddenly-black

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!