Android supporting multiple resolution with multiple layout folder

孤街醉人 提交于 2019-12-28 03:04:28

问题


Now I'm supporting multiple resolution with multiple layout folders. I'm using android development studio and I made 3 different folders.

layout
layout-large-port-1280x720
layout-normal-port-800x480 

and I tested on 800x480 and 1280x720. 480x800 worked well, but 1280x720 follow 800x480 folder's dp and UI.

I don't know why this thing happens to me and I don't know how to solve the problem. Why it doesn't work and what should I have to do?


回答1:


For Different screen size, The following is a list of resource directories in an application that provides different layout designs for different screen sizes and different bitmap drawables for small, medium, high, and extra high density screens.

 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      // layout for extra large screen size
 res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation

 res/drawable-mdpi/my_icon.png        // bitmap for medium density
 res/drawable-hdpi/my_icon.png        // bitmap for high density
 res/drawable-xhdpi/my_icon.png       // bitmap for extra high density

Thats code in the Manifest supports all dpis.

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



回答2:


make sure you have given the corresponding drawables in drawable-xhdpi

I don't know on what basis you're creating the App. But it's better to avoid creating layout for specific screen sizes.. Instead you would give the following:

layout-small-port for devices like samsung galaxy y

layout-normal-port for devices like galaxy s2

layout-large-port for devices like nexus 7 which is 7 inch

layout-xlarge-port for devices having more than 7 inch size

If you specify the screen size, you can't support more number of devices




回答3:


U should use:

res/layout/main_activity.xml           # For handsets (smaller than 480dp available width)
res/layout-sw480dp/main_activity.xml   # For phones (480dp wide and bigger)
res/layout-sw600dp/main_activity.xml   # For 7” tablets (600dp wide and bigger)
res/layout-sw720dp/main_activity.xml   # For 10” tablets (720dp wide and bigger)



回答4:


res/drawable – The default image folder
res/drawable-sw200dp
res/drawable-sw600dp
res/drawable-sw800dp


来源:https://stackoverflow.com/questions/20763322/android-supporting-multiple-resolution-with-multiple-layout-folder

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