开发者

How To Create Screen Size Independent Android Applications

I am working on android 2.2, I developed an application which is having an Image View and a button view. In HVGA both the image and button are visible, but in QVGA I could see only the image. Rest of the buttons that are present under the image view is not visible.

How do I manage multi-screen resolutions in Android ? Is开发者_StackOverflow中文版 there any thing like maintaining Aspect Ratio of the image to adjust the size as well maintain clarity.

I tried placing the buttons above the image view and it worked properly for HVGA and QVGA. Please let me know how can I handle the situation by placing the buttons below the image view.

I have done it in relative layout

Image width and height is fill_parent and wrap_content Button width and height is wrap_content and wrap_content.


If you don't have enough space, either scale down your picture when you are on a smaller screen and use another folder with a different version of the layout and resources like that :

res/layout/my_layout.xml            // layout for normal screen size
res/layout-small/my_layout.xml      // layout for small screen size
res/drawable-ldpi/my_icon.png       // icon image for low density

Or you can put the all screen in a ScrollView and set the orientation vertical, which will offer the possibility to scroll the screen and access the button.

you can find ample information about dealing with screen size management here


You should create different (xml) layout files for different screen sizes.

e.g. you could have your current one in res/layout/my_layout.xml, but one for small screens in res/layout-small/my_layout.xml.

See http://developer.android.com/guide/practices/screens_support.html for more details.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜