How To Create Screen Size Independent Android Applications
How To Create Screen Size Independent Android Applications
Screen Sizes: large, normal, small
Density: high (hdpi), medium (mdpi), and low (ldpi).
Here are some of the techniques we can use to create a screen-size independent application
Low density: 120dpi; Skin: QVGA (320px*240px).
Medium density: 160dpi; Skin: HVGA (480px*320px).
High density: 240dpi; Skin: WGVA800 (800px*480px).
Resources folders
So, thinking a bit about screen elements, sizes, densities... we can arrive at the conclusion that the size of the screen affects the views, and the layouts we create, and the density of the screen affects the images we set in the layout.One of the things we can do (there are many) is create layouts, views and images for every specific size and density. So, the resources directory could be something like:
res/layout/layout.xml
res/layout-small/layout.xml
res/layout-large/layout.xml
res/drawable-ldpi/icon.png
res/drawable-hdpi/icon.png
Like.
And after creating folder your file display look like ,
For Small Layout folder layout display like,
For Medium Layout in Layout Folder display like,
For Large Layout Folder display like,
Manifest
In Android , we have a new element in the manifest, theThis is a piece of the manifest:
android:largeScreens="false"
android:normalScreens="true"
android:smallScreens="true"
android:xlargeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true" />
After going through all the resources we can use in our application to create the most “screen-size” independent.
for each screen resolution you can do following things,
You need to create different layout for diff screen size. Support all screen you need to create following layout:
|




No comments:
Post a Comment