screen support multiple devices using layout-large,layout-normal and layout-xlarge folders

末鹿安然 提交于 2019-12-07 03:41:50

问题


I created layout-large, layout-normal and layout-xlarge in the res folder and I copied all the xml files to those layout folders

First, I want to ask what is the difference between layout (the default) and layout-normal folder?

I know if I run the application on big screen size the app will take the xml files from layout-xlarge. So I made all the elements in layout-xlarge look as I want using FrameLayout in tap2 10.1, but when I run it in note2 or s3 mobile it looks different because the screen size is not same.

So how can I make the the application run in tap2 10.1 (1,280 x 800) and note2 or s3 mobile (1,280 x 720) size?


回答1:


Here there is the official description of how support all the screen size. And as described the layout folders are:

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

So layout and layout-normal folder are the same, but in the new Android API there isn't no more the layout-normal folder, but only layout folder. Also you have to know if there isn't the specific layout of the screen size in witch the app is running, by default the app takes the "default" layout.

EDIT

You can have different screen resolutions in the same folder, as you can learn from this images:

If you want a more specific layout for specific resolution you have to detect at run time the exact screen size.




回答2:


From Supporting Multiple Screens, you should define layout folder like this

res/layout/my_layout.xml              // layout for normal screen size ("default")
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

(the screen type base on)

xlarge screens are at least 960dp x 720dp
large screens are at least 640dp x 480dp
normal screens are at least 470dp x 320dp
small screens are at least 426dp x 320dp


来源:https://stackoverflow.com/questions/17912190/screen-support-multiple-devices-using-layout-large-layout-normal-and-layout-xlar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!