Android Samsung S I9000 screen size and density issues

£可爱£侵袭症+ 提交于 2020-01-22 02:05:10

问题


I'm having problems with an app on the Samsung S I9000. The buttons on my app are much larger than they should be. In addition, the system is selecting res/values-small/ as a source of values. All in all, it's acting as if the device has a very tiny screen, even though it's supposedly 800x480 (I'm working in landscape mode). In fact, I can improve the situation by changing the values in res/values-small/styles.xml to even smaller font sizes than I was already using.

Display metrics are as follows:

 density = 2.0
 scaledDensity = 2.0
 densityDpi = 320
 widthPixels = 800
 heightPixels = 480
 xdpi = 320.0
 ydpi = 320.0

Can anybody explain why the device is scaling my graphics up so much and acting as if I have an extremely small display? More importantly, how do I fix it?

I've tried tweaking my manifest to set minSdk and targetSdk to a recent release, but that had no effect. Deleting values-small/ caused the app to use the default values/ instead, which only made the situation worse.


回答1:


Always use "sp" for font and rest as "dp"

place your image in corresponding folder as below

suppose your are using 36x36 image in for mdpi you need to use

drawable-mdpi - 36 x 36
drawable-hdpi - 48 x 48
drawable-xhdpi  72 x 72

3:4:6:8 ratio

There are some situations in which you might not want Android to pre-scale a resource. The easiest way to avoid pre-scaling is to put the resource in a resource directory with the nodpi configuration qualifier.

For example:

res/drawable-nodpi/icon.png

for example

you are using an font size as 14sp means it will automatically change for 320 DPI as

14×320÷160 =28

so now your font size is 28dp for xhdpi resolution phone.



来源:https://stackoverflow.com/questions/9529501/android-samsung-s-i9000-screen-size-and-density-issues

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