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.
example:
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
Same thing will be happend with your images :
res/drawable-mdpi/my_icon.png // bitmap for medium density
res/drawable-hdpi/my_icon.png // bitmap for high density
res/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:
- 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.
example:
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
Same thing will be happend with your images :
res/drawable-mdpi/my_icon.png // bitmap for medium density
res/drawable-hdpi/my_icon.png // bitmap for high density
res/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:
- Use
wrap_content
,fill_parent
, ordp
units when specifying dimensions in an XML layout file - Do not use hard coded pixel values in your application code
- Do not use
AbsoluteLayout
(it's deprecated) - Supply alternative bitmap drawables for different screen densities
No comments:
Post a Comment