简体   繁体   中英

Android- Image shape changed on screen rotation

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:

正常模式下的应用

屏幕旋转后

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): 右侧大于左侧

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.

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.

在此处输入图片说明

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

Best Regards

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM