Working with multiple screens in android

Posted on Updated on

As we all know Android devices comes in various screen sizes ranging from

  • QVGA (Quarter Video Graphics Array)240×320/ Low Density/ Typically Small Screen
  • WQVGA (Wide QVGA)24×400/ Low Density/ Typically Normal Screen
  • FWQVGA (Full Wide QVGA)240×432/ Low Density/ Typically Normal Screen
  • HVGA (Half Size VGA)320×480/ Medium Density/ Typically Normal Screen
  • WVGA800 (Wide VGA800)480×800/ High Density/ Typically Normal Screen
  • WVGA854 (Wide VGA854)480×854/ High Density/ Typically Normal Screen

In general Android consists of set of four generalized screen sizes small,normal,large and xlarge and set of four generalized densities ldpi,mdpi,hdpi and xhdpi. Now while designing UI for mutliple screens create different layouts for different screen sizes. For that create three new folders in the project resource folder ie “res” such as

  • res/layout/main.xml                       // default layout for normal screen size
  • res/layout-small/main.xml        // layout for small screen size
  • res/layout-large/main.xml         // layout for large screen size
  • res/layout-xlarge/main.xml      // layout for extra large screen size

Now add different icons drawables for different screen densities

  • res/drawable-mdpi/icon.png        // drawable for medium density 
  • res/drawable-hdpi/icon.png        // drawable for high density
  • res/drawable-xhdpi/icon.png       // drawable for extra high density
(Normally I prefer icon size of 32×32 px for ldpi, 48×48 px for mdpi and 72×72 px for hdpi)

Finally declare screen size support in the Manifest file as

Now after declaring layouts and drawables for various screen sizes the Android OS takes care of which resources should be used during runtime. It will automatically select the resources according to the device screen size and density.

For detailed tutorial check http://developer.android.com/guide/practices/screens_support.html

One thought on “Working with multiple screens in android

    android tutorial for beginners said:
    August 6, 2012 at 3:30 pm

    nice article…
    i can easy to work this..thanks for sharing this post..
    i keep touch with this…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s