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).
Asked
Active
Viewed 4.3k times
4 Answers
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.

Nakul
- 1,313
- 19
- 26

Vipul Purohit
- 9,807
- 6
- 53
- 76
-
Thanks Vipul!. Seems like a very glaring omission the android studio. How can we request for this feature to be added. – user2392650 May 17 '13 at 07:51
-
@vipul the link is very helpful – dmSherazi Nov 27 '13 at 15:45
-
2Copy your image and put into drawable folder and just right click on that one, you will get the option Create a 9 patch – Raja Jawahar Jan 19 '16 at 06:00
-
1It'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. – Anis LOUNIS aka AnixPasBesoin Jan 22 '17 at 02:08
-
the image created successfully but the image contain black borders – Arnold Brown Dec 21 '18 at 07:06
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).

ilomambo
- 8,290
- 12
- 57
- 106

Yevhenii Zapletin
- 273
- 3
- 7
-
@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. – Reinstate Monica Mar 06 '15 at 10:03
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!

CodeMonkey
- 1,426
- 1
- 14
- 32