Android: support multiple screens

Defining height, width and other parameters in the XML file is the better option rather than on run time.
Because XML files works as metadata (data carrier) to the activity and avoids alot of confusion when onCreate mothode in called.
Plus, create different folders for image quality (hdpi,xhdpi,ndpi,ldpi)

7 inch device use mhpi
10 inch devices use hdpi and xhdpi
While NEXUS tabs use hdpi and xhdpi irrespective of their size.
Mobiles use ldpi and ndpi.

Beauty lies here is that android device automatically pick-p the suitable content when found, i.e layout and image.
If not found it would first search other Layout folders,e.g a layout not found in x-large folder then it will search in large,then medium, small, which one of them suits the best ,(if a layout is not found in its respective folder).

Nexus will create alot of trouble for you.
To check how your layout would look on different devices, try using the options, which tells you how it would look on that device with those height width, present in the Graphical (view of a ) layout.

Leave a Comment