How to create nine-patch and use it in my App?
Asked Answered
A

6

18

I want to create a nine-patch image and use that in my App but I don't know how to create it?

I've searched through the Android source code on the Web and I can't seem to find any examples of this. I need a tutorial so that I can understand the process.

Amorino answered 17/10, 2011 at 11:29 Comment(2)
Have a look at the doc how to create .9.png and nine png images.Koss
These links may help you : androiddom.com/2011/05/android-9-patch-image-tutorial.html and higherpass.com/Android/Tutorials/…Chromatin
C
7

There's a tool included in the android sdk to create and test nine patch images: http://developer.android.com/guide/developing/tools/draw9patch.html

You can also create a nine patch file using every gfx package out there ( photoshop, paint.net, ... ) using the creation guideline here: http://developer.android.com/guide/topics/graphics/2d-graphics.html#nine-patch

Connieconniption answered 17/10, 2011 at 11:36 Comment(0)
S
23

I have searched the best and the simplest answer to make 9-patch image. Now to make the 9 patch image is the easiest task.

From HERE you can make a 9-patch image for all the resolutions - XHDPI,HDPI,MDPI,LDPI in just one click.

Let me know if you have any queries, and do upvote it, if it was helpful to you.enter image description here

Spindell answered 3/4, 2013 at 9:50 Comment(3)
Other Links are also useful in this linkAdamik
Can't set more than 1 vertical area for stretchingArmchair
Link is broken.Chemesh
A
20

I just found that awesome alternative 9patch editor (by Mikle Garin) and I think it 1000% better than standard one built in sdk:

Editor JAR download link
Editor source code
Editor official page

enter image description here

Artemas answered 7/2, 2012 at 16:25 Comment(2)
Thanks for the kind words about my app! :) I am working on updating the editor application and will upload it on the WebLaF site. Some more features (like multi-images editing) are coming there. Plus there is already newer version than the one you have posted on screenshot with some useful features added aswell.Maladjusted
this is a beautiful toolViera
C
7

There's a tool included in the android sdk to create and test nine patch images: http://developer.android.com/guide/developing/tools/draw9patch.html

You can also create a nine patch file using every gfx package out there ( photoshop, paint.net, ... ) using the creation guideline here: http://developer.android.com/guide/topics/graphics/2d-graphics.html#nine-patch

Connieconniption answered 17/10, 2011 at 11:36 Comment(0)
P
5

I've created a tool that allows automatically create 9-patch images from regular PNG images for simple cases where stretchable areas are 1 pixel wide. Here's sample input and output (showed at 400%):

input output 400%

Project page on github

Pasquinade answered 28/12, 2011 at 16:9 Comment(0)
P
3

A NinePatch image is a standard PNG image created with Photoshop, Illustrator, Paint... etc. To add a NinePatch rule to it, just drag/drop it on the draw9patch.bat tool in your Android SDK directory.

IF you don't use the draw9patch.bat tool, you must include an extra 1px transparent border to draw the NinePatch rules with a 1px black (#000000) pencil size before you save it.

Important!!! Save the image with the extension myimage.9.png as a transparent PNG-8/PNG-24.

Image: Explanation of NinePatch graphic rules

Priming answered 11/11, 2011 at 0:12 Comment(0)
O
0
http://android-ui-utils.googlecode.com/hg/asset-studio/dist/nine-patches.html 

Although android provides the tool for ninepatch images .Open terminal and go to android sdk -tools path and type ./draw9patch. But this is the best link you can make for all density in just one click.
Ooze answered 2/7, 2013 at 12:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.