0

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.

Edward Falk
  • 9,991
  • 11
  • 77
  • 112
  • I dont think there is an folder with values-small. you can use values-large and values-xlarge also. whats your android OS version? – Padma Kumar Mar 02 '12 at 07:53
  • There is a values-small. See http://www.efalk.org/SamsungS.tar.gz for source code that includes it and demonstrates it on any small-screen device, and apparently the Samsung S as well. I believe it's been supported since 1.6. See http://developer.android.com/guide/practices/screens_support.html – Edward Falk Mar 06 '12 at 14:53
  • Bottom line: I'm convinced it's a bug in the Samsung S -- it reports pixel density as 320 when it's really 233. This causes all graphics to be scaled up by 2x when it should really have been 1.5x. It also causes the screen size to be computed as 1.5" x 2.5" which really would be a small screen if that were true. Has nobody noticed that the icons, menus, etc. on the Samsung S are really huge? They're huge on the emulator. – Edward Falk Mar 06 '12 at 15:00
  • Dont confuse with PPI and your dpi. its different. if your phone returns pixel density as 320 mean its xhdpi only dont confuse with your 233 ppi. – Padma Kumar Mar 06 '12 at 15:22
  • I'm confused; what's the difference between PPI and DPI? The Samsung Galaxy S physically has 233 pixels per inch. The screen has a 4" diagonal. Why would it ever report 320 or that it's a small screen? – Edward Falk Mar 06 '12 at 18:08

1 Answers1

2

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.

Padma Kumar
  • 19,893
  • 17
  • 73
  • 130
  • Thanks. I am using sp for fonts; I assume it gets scaled by either density or scaledDensity? None of this explains why the system is taking resources from res/values-small. Or is that because the device has an unusually small screen despite its high pixel density? – Edward Falk Mar 02 '12 at 15:53