Best way to handle various Android screen sizes?

We are writing an application for T-Mobile MyTouch, which is an Android mobile phone. We have images that will be displayed in the default screen mode (320 x 480).

Assuming Android OS appears on netbooks with a standard 16: 9 format by default, what is the best way to handle images that are in portrait mode format? In other words, since you cannot rotate the screen on these netbooks, if you display the image in portrait mode in landscape mode, there will be large empty rectangles on both sides of the image.

+4
source share
3 answers

In terms of image resources in an application, for example, with background images, a common practice is to have different image settings for landscape and portrait modes or even different screen sizes. Of course, you adapt your layout to it, or at least have a good relative layout.

However, if you are interested in what to do when an image with an unknown size should be drawn on the screen (for example, in the case of a photo album application), stop leaving these black rectangles on both sides. Take a look at the behavior of the video player on Android Dev Phone 1. It will adapt the height of the video frame to landscape mode and will play video in landscape mode regardless of whether portrait mode is suitable.

+3
source

You deal with this in the same way as with a user turning the phone to the side. This is the same presentation solution as the user interface.

Remember that Android supports alternative layouts for identical views. If you have a portrait layout, for example. res / layout / gallery.xml , you can create a landscape equivalent in res / layout-land / gallery.xml , and Android will automatically download the last layout file if the action starts in landscape mode.

Using a separate layout XML file, you can organize your image as it seems to you, it best suits the intent of your application (an application that displays medical images may have different presentation priorities than one that displays a family portrait). For example, you can simply fill the background with a gradient or more information that is otherwise hidden in portrait mode. It all depends on what you want to achieve using your application, and on how much you are willing to go to account for all the possibilities.

But ultimately, if the user can see the image in it, without requiring turning over their netbook on it, I think they will be happy :)

+3
source

You must design your screen with specific anchor points, and then place the rest of the views with respect to these anchor points. For example, if you have a screen layout with a banner, a list of elements and some buttons in the list, and then two ways to place them on the screen:

  • Place the banner at the top. Place the list below it, and then the buttons on the list.
  • Place the banner on top. Place the buttons on the bottom of the screen, and then the list takes up the space between the banner and the buttons.

Layout 1) will have problems with different screen sizes, and the layout will look strange or may not display correctly. While 2) gives you the best look for most screen sizes.

0
source

All Articles