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

旧时模样 提交于 2019-12-02 19:21:38

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

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.

deviant

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

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%):

Project page on github

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

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