Convert png images to 9 patch in Android Studio
Asked Answered
G

4

30

In android studio,you can edit 9 patches directly from with the IDE. But is it also possible to convert an png image to 9-patch using the IDE? (similar to the android 9-patch tool provided by the SDK).

Gibert answered 17/5, 2013 at 6:12 Comment(0)
L
35

Well I don't think there is any tool in Android Studio but you can do this by Android Asset Studio

Android Asset Studio Simple Nine-patch Generator

This is a very handy tool to create simple 9 patch images for all dpi with a clean user interface.

Lepage answered 17/5, 2013 at 6:54 Comment(5)
Thanks Vipul!. Seems like a very glaring omission the android studio. How can we request for this feature to be added.Gibert
@vipul the link is very helpfulTeens
Copy your image and put into drawable folder and just right click on that one, you will get the option Create a 9 patchVicinity
It's possible nowadays with Android studio. Right click on your png, make it a 9 patch and then double click on it and the magic will happen.Argilliferous
the image created successfully but the image contain black bordersThermogenesis
F
20

If you rename the resource from *.png to *.9.png then in Android Studio you may edit it with 9 patch (a tool provided with the Android SDK).

Froehlich answered 18/5, 2013 at 21:10 Comment(1)
@Paschalis You're correct. When I renamed the file manually, Android Studio initially recognised it and let me edit it as a 9 patch image, but it wouldn't compile. The name contained illegal characters, I'm guessing the full stop. CodeMonkey's answer worked though.Strophanthus
F
18

Android Studio now has this option available by right-clicking on the image file in your res folder, then selecting Create 9-Patch file. You can then open the newly created 9-patch file and start editing!

Florist answered 24/3, 2014 at 4:18 Comment(0)
M
2

Update: Android Studio now has a feature that can be used to generate 9patch images. To do this navigate to /home/android-studio/data/sdk/tools on your terminal and run draw9patch.

Mogilev answered 10/10, 2014 at 11:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.