tags:

views:

864

answers:

2

Hello,

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.

Any ideas? =)

regards

+3  A: 

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.

Jeff Gilfelt
Thx! the problem was that I named it .9.png at first =)Now, the next problem is that I cannot add the "bottom" line since that "1 pixel perimiter" doesnt exist at the bottom, only to the left. Thus, I can add the line on the left, but not on the bottom or top - I cant see the perimiter there. any tips?
Ted
update: ok I can add the top, but the "perimiter" is hidden by the message "Press Shift to erase pixels"... Bottom is still a mystery, and to mark the right side is a hazzle since I need to scroll all the way to the right, so i cant see the image/shape anymore.
Ted
update 2: It is a scrolling problem it seems. If I fibble around with the right pane, I sometimes get the right "perimiter" that is usually missing. Bottom is still gone though.
Ted
update 3: ok, got it. Just made the image smaller, so no scrolling was required and then the perimiter showed up =)
Ted
+2  A: 

The 9-patch tool is a bit awkward to use, but it does work. I believe you need to left click and drag around the edge to paint the outside border.

Alternatively, you can use any image editor and create a one pixel empty border around it, and draw in the following:

Top/Left = black pixels for the area of the image that can be grown or shrunk as needed. For a typical border, it is everything except for the curved corners

Bottom/Right = black pixels for the small snippet that should be repeated if the image needs to be grown in that direction.

Mayra