Monday, 19 September 2011

Layout design for different - 2 screen resolution

In Android this is the main thing to maintain the layout according to screen resolution. But thid can be done now easly. Android 3.2 has introduced new APIs that allow you to more precisely control the layout resources your application uses for different screen sizes.

  • Android groups all actual screen sizes into four generalized sizes: small, normal, large, and extra large.
  • Android groups all actual screen densities into four generalized densities: low, medium, high, and extra high.
  • A virtual pixel unit that you should use when defining UI layout, to express layout dimensions or position in a density-independent way.
Now You can create different - 2 layout resolution wise and place them in your application.


res/layout/my_layout.xml             // layout for normal screen size ("default")
/layout-small/my_layout.xml       // layout for small screen size
/layout-large/my_layout.xml       // layout for large screen size
/layout-xlarge/my_layout.xml      // layout for extra large screen size
/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation

Same thing will be happend with your images :

res/drawable-mdpi/my_icon.png        // bitmap for medium density
/drawable-hdpi/my_icon.png        // bitmap for high density
/drawable-xhdpi/my_icon.png       // bitmap for extra high density

Here is a quick checklist about how you can ensure that your application displays properly on different screens:
  1. Use wrap_content, fill_parent, or dp units when specifying dimensions in an XML layout file
  2. Do not use hard coded pixel values in your application code
  3. Do not use AbsoluteLayout (it's deprecated)
  4. Supply alternative bitmap drawables for different screen densities
For more you may reffer Android Developer site

No comments:

Post a Comment