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).

Lucifer
  • 29,392
  • 25
  • 90
  • 143
user2392650
  • 303
  • 1
  • 3
  • 4

4 Answers4

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
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
  • @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
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.

Tom11
  • 2,419
  • 8
  • 30
  • 56
Udo
  • 1,129
  • 3
  • 15
  • 30