2. Android devices are available in screen sizes and resolutions, Hence multiple screen size in android UI design
is most important.
Screen size : Actual physical size, measured as the screen’s diagonal.For simplicity, Android groups has four
generalized sizes: small, normal, large, and extra large.
Screen density : The quantity of pixels within a physical area of the screen; usually referred to as dpi (dots per
inch).For simplicity, Android groups has four generalized densities: low, medium, high, and extra high.
Orientation : The orientation of the screen from the user’s point of view.In Android, This is either landscape
or portrait.
Resolution : Default screen size with with the total number of physical pixels on a screen.In Android, we do
not work directly with resolution; applications should be concerned only with screen size and density
TERMS AND CONCEPTS
3. Mainly this things done by three ways.
1. Explicitly declare in the manifest which screen sizes your application supports.
2. Provide different layouts for different screen sizes.
3. Provide different bitmap drawables for different screen densities.
4. 1. Explicitly declare in the manifest which screen sizes your application supports
Add the <support-screens> element into the AndroidManifest.xml file. This field specifies which screen size support and
which do not.
<?xml version="1.0" encoding="utf-8"?>
<manifest ..>
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens= "true"
android:anyDensity="true"
/>
<application... >
………..........
</application>
</manifest>
we can also define dp in the <support-screens> element like-
<manifest >
<supports-screens android:requiresSmallestWidthDp="600" />
</manifest>
5. Mainly this things done by three ways.
1. Explicitly declare in the manifest which screen sizes your application supports.
2. Provide different layouts for different screen sizes.
3. Provide different bitmap drawables for different screen densities.
6. 2. Provide different layouts for different screen sizes
As we design our UI for different screen sizes, we’ll discover that each design requires a minimum amount of space. So,
each generalized screen size above has an associated minimum resolution that’s defined by the system. These
minimum sizes are in “dp” units.
res/layout/my_layout.xml // layout for normal screen size ("default")
res/layout-small/my_layout.xml // layout for small screen size
res/layout-large/my_layout.xml // layout for large screen size
res/layout-xlarge/my_layout.xml // layout for extra large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation
We can also define it on the basis of dp like –
res/layout/main_activity.xml // For handsets
res/layout-sw600dp/main_activity.xml // For 7” tablets(600x1024 mdpi).600dp wide and bigger.
res/layout-sw720dp/main_activity.xml // For 10” tablets (720x1280 mdpi).720dp wide and bigger.
7. Mainly this things done by three ways.
1. Explicitly declare in the manifest which screen sizes your application supports.
2. Provide different layouts for different screen sizes.
3. Provide different bitmap drawables for different screen densities.
8. 3. Provide different bitmap drawables for different screen densities
To set labels for different layouts, dimensions or different screen density resources, use the following resource
directories:
For example:
res/drawable-hdpi/myImg.png // bitmap used for high-density
res/drawable-mdpi/myImg.png // bitmap used for medium-density
res/drawable-ldpi/myImg.png // bitmap used for low-density
res/drawable-xhdpi/myImg.png // bitmap used for extra high density
We can also define it on the basis of dp:
res/layout/main_activity.xml // For handsets
res/layout-sw600dp/main_activity.xml // For 7” tablets(600x1024 mdpi).600dp wide and bigger.
res/layout-sw720dp/main_activity.xml // For 10” tablets (720x1280 mdpi).720dp wide and bigger.
9. Handing Screen Density
We can develop our application to maintains the physical size of the interface by using match_parent and
wrap_content values for android:layout_width and android:layout_height. This parameter does not specify size but
adapts to the space available.
...
android:layout_width = "match_parent"
android:layout_height = "wrap_content"
...
Bitmap scaling can result in blurry images. To prevent this, provide higher-resolution bitmaps for high-density screens
and the system will use those instead of resizing the bitmap designed for medium-density screens.