0

I tried to create an emulation of the Samsung Galaxy II i9100. All I really care about is screen size and pixel density. I created the following device definition:

enter image description here

And this virtual device:

enter image description here

But the emulated device looked like this:

emulated resources

Why was the resulting size 480x736? And the dpi value is slightly off.


ETA: here is what my app looks like:

calculator with bottom cut off

And here is the output of ShowResources on an actual Samsung S2 i9100

enter image description here

Edward Falk
  • 9,991
  • 11
  • 77
  • 112

1 Answers1

2

First Galaxy S2 is HDPI, not TVDPI, also note that TVDPI is not a "primary density group" per Android documentation:

Resources for screens somewhere between mdpi and hdpi; approximately 213dpi. This is not considered a "primary" density group. It is mostly intended for televisions and most apps shouldn't need it—providing mdpi and hdpi resources is sufficient for most apps and the system will scale them as appropriate. If you find it necessary to provide tvdpi resources, you should size them at a factor of 1.33*mdpi. For example, a 100px x 100px image for mdpi screens should be 133px x 133px for tvdpi. source: http://developer.android.com/guide/practices/screens_support.html

On why the screen report 480x736, the 64 pixels is used by the system soft buttons (back, home, recent apps). To remove the soft buttons, you have to use/create a Device Definition that sets Buttons option to "Hardware", as exemplified below: enter image description here Alternative you can use Nexus S's Device Definition, it would have the correct buttons and DPI settings.

Kai
  • 15,284
  • 6
  • 51
  • 82
  • Well, I got the pixel size I asked for, but the emulated dpi is 240, even though it should be ~217. I hand-edited devices.xml and set the dpi to 217 but didn't get what I expected. I also edited the config.ini file and restarted Eclipse. No joy. Why does Google hate us? – Edward Falk Jan 25 '14 at 18:28
  • I am going to guess that you are new to Android development. There's a concept of "DPI buckets" that groups all possible Android screen densities into LDPI (120), MDPI (160), HDPI (240), XHDPI (320), XXHDPI (480). This allows developers a set of target that they should build their art assets, otherwise it'd be pretty hard if you have to build a set of artworks for 217,233,252ppi devices... etc. In the real world I found it to work extremely well, which why Android devices have such diversity in screen sizes and resolutions while iOS devices are confined to simply a doubling in screen density. – Kai Jan 26 '14 at 01:01
  • If you have not already, I strongly recommend reading everything here: http://developer.android.com/guide/practices/screens_support.html – Kai Jan 26 '14 at 01:03
  • Actually, I'm a long-time Android developer and understand screen support pretty well. Unfortunately, I'm trying to debug an issue on a Samsung S2 i9100 in which a small amount at the bottom of my app is cut off. No matter how I configure the emulator, my app always looks perfect, but my customer has sent me a screen shot showing the problem. The last time this came up, I actually visited Samsung HQ and borrowed a device for testing, but I don't want to do that again, so I was hoping to emulate the i9100 *exactly* to reproduce the problem. – Edward Falk Jan 26 '14 at 02:38
  • Worth noting: the i9100 has a "Pentile" display, which boosts effective resolution by only having half as many blue pixels. It's caused me no end of subtle problems in the past. – Edward Falk Jan 26 '14 at 02:40
  • @EdwardFalk Ah ok I assumed wrong then, sorry about that. Do you have a screenshot of the problem you are having? If it's just that particular device, a quick (and dirty) fix is to check the device your app is on and manually adding the required padding for S2. Had to do this for a certain Moto device because its TTS is a bust. – Kai Jan 26 '14 at 02:44
  • Screen shot added to original question. – Edward Falk Jan 28 '14 at 06:39
  • BTW, I wrote a handy tool for diagnosing these things. It's called "ShowResources", it's on the Android Market, and it's free. – Edward Falk Jan 28 '14 at 06:39
  • It looks like the problem is that the height your app requires is larger than what the screen has in landscape mode though, you don't have the same issue with other 480x800 HDPI devices? Also, have you gotten the emulator to have the same display parameters as S2? – Kai Jan 28 '14 at 07:00
  • The app looks perfect on other 800x480 devices. I haven't been able to get either the Google or Genymotion emulators to give me 217 dpi. – Edward Falk Jan 28 '14 at 16:47
  • Hmm I've not encountered such an issue. Considering that S2 is an old device, I think you can just do a hack solution for this particular device or devices of similar dimension and DPI – Kai Feb 01 '14 at 03:33
  • That's what I've been trying to do -- even to the point of hand-editing the config files that the UI generates. Nothing gives me 800x480 @ 217 dpi. – Edward Falk Feb 02 '14 at 03:11
  • How about just align your calculator controls to the bottom of the screen, and on S2 uses a smaller font size for texts in the calculation area? – Kai Feb 02 '14 at 03:14
  • I'm trying to control the font sizes from resource files alone -- can I make a resource file for a specific device? – Edward Falk Feb 02 '14 at 03:24
  • The only way I can think of is to create 2 layout XMLs for this screen where you move all common layouts (such as the controls) to their own XML files, and the only difference between the 2 layouts would be the font size of TextViews. – Kai Feb 02 '14 at 03:27