Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Draw 9-patch not working - cannot edit image

Tags:

android

after I found out (sadly) that there is no easy way to create a simple border around a View, I was forced to use the 9-patch-image approach to get a border around my View.

So I read the short thing there is on the 9-patch and its easy enough to understand. I started the "Draw 9-patch" application that came with the Android SDK, opened up a very simple image I created in Paint and then... I got stuck.

According to the page (http://developer.android.com/guide/developing/tools/draw9patch.html) I should be able to define those areas where the image can be expanded and so on, just by clicking on the edges ("Click within the 1-pixel perimeter to draw the lines that define the stretchable patches...").

So I try to do just that and absolutely nothing happens. I try to hold down SHIFT when clicking and also do the rigth-mouse-click, and nothing happens. When I move the mouse away from the 1-pixel perimiter I get a grey-and-red "marquee" (stripes).

Bottom line is: nothing happens no matter what I do.

like image 977
Ted Avatar asked Jan 04 '10 20:01

Ted


People also ask

How do I create a 9 patch image in Photoshop?

Creating 9 patch background image using Photoshop:Draw the images in a regular way as you use to do in Photoshop. Make the 1px spacing around the image from all sides. And also make sure that the image doesn't have anything in this 1px area & has 100% transparency. Otherwise 9patch image will not work.

How do I create a 9 patch image in sketch?

In Android Studio, right-click the PNG image you'd like to create a NinePatch image from, then click Create 9-patch file. Type a file name for your NinePatch image, and click OK. Your image will be created with the . 9.

What is 9 patch image in Android?

A 9 patch image is a regular png (. PNG) image which is needful for android app developers where they require to wrap any content within a background image without pixelating the background image.


1 Answers

The tool definitely works, but make sure the image you create first does NOT have the .9.png extension. If it does, the draw9patch tool will assume the 1 pixel perimeter of your image is already setup as 9-patch. If you open an image with just a .png extension, the tool will add the 1 pixel perimeter and you will be able to manipulate it as described, and save it as 9-patch when you're done.

like image 81
Jeff Gilfelt Avatar answered Oct 17 '22 14:10

Jeff Gilfelt