Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could anyone help me with creating 9 patch image from a png image?

I am creating a chat application.I want the to convert my png image for chat bubble into a 9patch image.I used this link.... http://android-ui-utils.googlecode.com/hg/asset-studio/dist/nine-patches.html

But the problem is that the chat bubble is always maintaining a minimum width even for small messages.For eg,if i type a text like "hello",it is displayed in a bubble of width much more than the message.How to create 9patch image properly ??

Here is my png image

enter image description here

like image 526
Nevaeh Avatar asked Mar 27 '14 07:03

Nevaeh


2 Answers

Your 9-patch image needs to be smaller than your smallest message. The system will expand 9-patch images, but will never shrink them in the 9-patch way. Also, make sure the name of your image file ends in ".9.png".

Here's an edited image that you can use in the Android Asset Tool to create your set of 9-patch images:

enter image description here

The following image shows how you should define your stretch regions in the 9-patch generator. You'll get a zip file with p-patch images in a few different densities. Put these into your drawables folders.

enter image description here

like image 147
scottt Avatar answered Sep 24 '22 19:09

scottt


  • There is a tool distributed along with the SDK called draw9patch. It should be already there in your SDK folder. Check <sdk-directory>/tools/draw9patch. This tool is easy to use and quite intuitive. Learn more about draw9patch here.

enter image description here

  • On the other hand, you can use the Android Asset Studio cloud app here.
like image 25
C-- Avatar answered Sep 23 '22 19:09

C--