0

I have created a Nine Patch image using the tool provided with android sdk. The problem is, the tool is showing bad patches in the image. As you can see in the image below enter image description here

My image is stretching weirdly.

Please follow: Android- Image shape changed on screen rotation

My question is, what is this bad patch? Android documentation did not help. :(

And how can I fix them??

Community
  • 1
  • 1
Aman Gautam
  • 3,549
  • 2
  • 21
  • 25

4 Answers4

1

Your logo image is not at all expanding weirdly, but just as you set it: you told it to stretch the middle(the pink area), and it's just what it's doing.

I think in this case you'd rather want only the corners (before and after, below and under the text) to stretch, as you can see in my image below(you can see the text is not stretched at all). There are still some bad patches, but they will only stretch some 'same-color' portions.

enter image description here

Adinia
  • 3,722
  • 5
  • 40
  • 58
0

Seems like other people have had this issue before.

Bad 'Patches' in 9-Patch File

You might want to show us what you mean by "stretching weirdly". If you are using the 9patch tool, take a screenshot of the right side of that tool where the boxes are stretched. If you show us what you mean by weird, we might be able to help you out.

Community
  • 1
  • 1
Gophermofur
  • 2,101
  • 1
  • 14
  • 14
  • Please have a look at the image : http://i.stack.imgur.com/tHU4k.png to see what I mean by weird. The rightmost portion is larger than the leftmost portion and this looks really weird in a real device. :( – Aman Gautam Apr 30 '12 at 15:34
  • I can't seem to follow along. That image looks fine to me? The right side doesn't seem taller than the left side? – Gophermofur Apr 30 '12 at 15:54
0

The top and left sides of the image tell the 9-patch to stretch wherever you paint black. The bottom and right sides tell it to make sure that any content (such as a TextView) that uses this 9-patch for a background should size the image so those bars cover the content. So: Top/Left = "Stretch here", Bottom/Right = "until this rectangle covers the content." Since your content is part of the bitmap, you don't care about the bottom/right.

Sparky
  • 8,437
  • 1
  • 29
  • 41
-2

The image worked perfectly fine when stretched, the "weirdness" was because of an optical illusion from the background. The bad-patch was possibly just a warning.

Aman Gautam
  • 3,549
  • 2
  • 21
  • 25