0

I created an app that uses a 9.png file as its background. The problem is, when I rotate the screen, the background shape changes weirdly.

I am attaching the screenshot:

Application in normal mode

After Screen Rotation

As you can see, the background of the layout containing the name and image takes a weird shape.

What can be the possible reason? And how can I make it work?

I have checked that the image is perfectly smooth and in perfect shape.

EDIT: I am talking about the following background that is not stretching properly(The leftmost part is smaller in height than the rightmost part): The right portion is larger than the left portion

Aman Gautam
  • 3,549
  • 2
  • 21
  • 25
  • Have you by any chance made the "autocar experts" text part of the stretchable area? – MH. Apr 29 '12 at 19:12

3 Answers3

0

You need to use 9patch to define what areas of the image are allowed to stretch when the orientation changes. Check out this link for 9patch.

JustinDanielson
  • 3,155
  • 1
  • 19
  • 26
0

The top and left edges of your 9-patch are where you declare which parts of your image can stretch to fill the space. Since you have what appears to be a bitmap with content in the middle (as opposed to a background bitmap), you should prevent the logo in the center of your 9-patch from stretching. That means you want the black borders in position where you might draw the lines on a Tic-Tac-Toe board: Not through the middle, and not in the corners either. See where I put the stretch bars (okay, dots really) on this example image.

enter image description here

Sparky
  • 8,437
  • 1
  • 29
  • 41
  • Thanks Spanky, Actually I am talking about the background behind Toyota Camry W2 Diesel. Sorry, I possibly did not make it clear enough. – Aman Gautam Apr 30 '12 at 15:20
  • Oh, that. It looks like you're aligning the top of the photo to the bottom of the label or something. To me it looks the same in both of your screen shots. Are you sure rotation is a factor? Anyway, if you can post the XML that defines your list item layout, maybe we can tease something from it. – Sparky Apr 30 '12 at 19:57
-1

I have found the problem. It is an optical illusion, because of the background image. It is now fixed.

Best Regards

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