Drawables are always read from mdpi folder, regardless of screen size

核能气质少年 提交于 2019-12-22 07:57:25

问题


I am trying to create an application that works both on Samsung galaxy tab GT P1000 and samsung galaxy tab 10.1; The samsung galaxy tab 10.1 (1280 * 800) has a much bigger screen than that of the GT P1000, so I am assuming the GT P1000 should read from hdpi, and 10.1 should read from xhdpi. The surprise is that both of them are reading from the mdpi folder. Regards


回答1:


Large screen size does not necessarily means high pixel density. For pixel density you have to consider both physical screen size and screen resolution.

For example consider Galaxy Note 1 and Galaxy Tab 10.1, both have screen resolution of 1280*800 but galaxy tab 10.1 has physical screen size of 10.1 inch whereas galaxy note has physical screen size of 5.3 inch, which is almost half of galaxy tab size. Thus galaxy note has more pixel per inch than galaxy tab 10.1 and it has xhdpi density, where as galaxy tab 10.1 has mdpi density, check density values in this link-

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

For 10.1 tab you should use drawable-xlarge-mdpi folder and GT P1000 should also use mdpi but as I have seen on many online posts that GT P1000 has problem, it has mdpi density but it uses drawables from hdpi, I have not checked myself so for GT P1000 you can try to use drawable-large-hdpi folder, if drawable-large-mdpi does not wok.

And also add xlarge support in your manifest.

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

You have to use 2.3 and above sdk for using xlarge as it was added later.




回答2:


mdpi refers to the screen density, in dots per inch, not the overall size. I presume that both devices have similar densities, so they load resources from the mdpi folder.

You can have separate layout resources based on the actual screen size (large/medium/small) rather than the density. Refer to the documentation.




回答3:


Just Make new folder name drawable-xlarge-mdpi and paste all images in it.. Device will automatically get from that folder..!

My problem with Galaxy Tab2 was solved!



来源:https://stackoverflow.com/questions/7634492/drawables-are-always-read-from-mdpi-folder-regardless-of-screen-size

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