How my android app will run on multiple screen res

2019-05-20 19:19发布

问题:

I have developed an android application and run it on an HVGA emulator. It's running successfully on any HVGA device i.e. mdpi. But if I try to run on small screen resolution devices i.e QVGA then my buttons are looking as if they go down and dont fit onto the small screen...

So how can I run my android application on multiple screen resolution successfully?

回答1:

follow these instructions

  1. create a folder in yourAppFolder/res/ named layout-small (*more on this subject later)
  2. insert in this folder all your xml layout items that need special treatment for a small screen (it is not necessary to copy all of "normal" layout files, but you can if you wish)
  3. change the files in this layout as needed

What happens with this approach:

if the device has a non-small screen, the default layout (the one in "layout" folder) will be loaded and used, otherwise if the screen is in "small" category the files in "layout-small" will be used instead (only if one with the same name is available, otherwise the one in "layout" will be used

*About folder naming: that policy was the old one supported by android. Nowadays there is another one, more precise but more complex too (example: specify minimum necessary width). Anyway, this is still supported, just note that eclipse may suggest you some alternatives. Currently, i am still developing with the old naming policy.



回答2:

I think it is better to design your layout for every screen size and resolutions. It is easy in android. Copy your layout from "layout" folder of resources and paste it in the "layout-land", "layout-xlarge", "layout-xlarge-land" and ... folders and change those settings you need in them.

you can check this link:



回答3:

In the UI builder (part of the Eclipse plugin), you can build your interfaces for multiple screen sizes and resolutions. To make different layouts for different resolutions, simply follow these instructions to build alternate layouts:

http://developer.android.com/guide/practices/screens_support.html#support