开发者

Android generic application requirement

I want to develop an Android application which can run on all ,screen type ,Android phones. So my question is:

Would it be okay to to keep all image resources in HDPI folder only? Or will I need all 3 type of resources LDPI , MDPI AND HDPI?

If I use relative layout for developing this app so what would happen for the images which have some text on it ( _ button background image which will have some text "Submit" ). Android will scale the image according to device 开发者_运维百科screen but is it capable to scale text also accordingly?

Please suggest me how to deal with this problem.

How to make an app which can work on all type screen Android phones?


To develop a android application that has mutiple screen support you must go through this tutorial in brief:Android Mutiple Screen Support

In gist of your questions:

1.The specific asset in drawable are automatically taken depending on density. So you should place specific images in mdpi,hdpi,ldpi accordingly.

2.Read and understand manifest support screen tag values:

<supports-screens android:smallScreens="true"
        android:resizeable="true" android:largeScreens="true"


        android:anyDensity="true" android:normalScreens="true"></supports-screens>

3.The Text should be resized:

You should use styles, then you can have separate folders "values" (default) "values-hdpi" (high density) "values-mdpi" (medium density) and so on and put your style file with correct textSize values in each folder as needed.

Then, when you are in medium density device it will pick the file in "values-mdpi" folder if exists or in "values" if not, and the same for high density etc...

This same principle applies to al "res" subfolders (drawables, values, etc...)

Or Simply If do not go for styles just use dp instead of sp for text dimension.


If you put images in HDPI folder only, it will work. but ideally you should put images according to density. also if you use 9 patches image on button background, android stretches the images according to requirement however if in some case you find that image are not properly stretching you can use separate images for landscape and portrait mode.


If I use relative layout for developing this app so what would happen for the images which have some text on it ( e.g a button background image which will have some text "Submit" ) . android will scale the image according to device screen but is it capable to scale text also accordingly?

=> If you want to provide scalable images which can be shrinked/stretched automatically as per the screen size, then there is a 9-patch tool by which you can create a scalable image and after that you don't need to worry about the screen size and screen density.

Here is a nice example: http://www.dibbus.com/2011/03/9patch-images-in-android/

Here is also a nice article and guide to create 9-patch image: http://radleymarx.com/blog/simple-guide-to-9-patch/

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜