简体   繁体   中英

android: screen size layout change

i created 4 folder for layouts with different screen size:

  • layout-small
  • layout-normal
  • layout-large
  • layout-xlarge

My problem is now that that the layout from the samsung galaxy s2 and samsung galaxy s4 mini takes the layouts from the folder 'layout-normal'. How can I change that the device samsung galaxy s4 mini does take the layouts of the folder 'layout-large'?

You would have to create new folders for example layout-sw600dp or layout-sw720dp in order to get the samsung s4 layout not to use from layout-normal.

More details are at : http://developer.android.com/guide/practices/screens_support.html

But as a summary it means, (from the website)

Specifically, the device's smallestWidth is the shortest of the screen's available height and width (you may also think of it as the "smallest possible width" for the screen). You can use this qualifier to ensure that, regardless of the screen's current orientation, your application's has at least dps of width available for it UI.

For example, if your layout requires that its smallest dimension of screen area be at least 600 dp at all times, then you can use this qualifer to create the layout resources, res/layout-sw600dp/. The system will use these resources only when the smallest dimension of available screen is at least 600dp, regardless of whether the 600dp side is the user-perceived height or width. The smallestWidth is a fixed screen size characteristic of the device; the device's smallestWidth does not change when the screen's orientation changes.

Use foldernames like layout-sw320dp instead.

You can read about it here http://developer.android.com/guide/practices/screens_support.html under Using new size qualifiers

An unofficial solution is create an alternative layout folder for galaxy s4 mini, the name is layout-960x540, by this way all devices that have screen resolution 960x540 will take the layouts from this folder, I say unofficial because I see this way just work for layout and values, not drawable and I also not sure if there is a document for this on google but it works. Hope this help.

From android 4.0 and above you have to create new folders for example layout-sw600dp or layout-sw720dp in order to get the samsung s4 layout. Also provide the proper drawables in respective folders.. check the link for more details http://www.c-sharpcorner.com/UploadFile/e14021/multiple-screen-support-in-android-using-android-studio/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM