1

I've been having problems with my app on a 7 inch device. For debugging purposes I've added a toast message that displays after the app loads, to tell me which resource folder the app is using, ie. which qualifiers. I have strings.xml files in each of the following resource folders:

values

values-normal

values-large

values-xlarge

values-sw600dp

values-sw720dp

The content of the string used by the toast message is based on the folder in which the string is located. I also have six layout folders with the same qualifiers as above, and I have valid layout xml files in all six of the layout folders. My app works perfectly on 'normal' screens and 10 inch tablet screens.

The troublesome 7 inch device (my mate's) is a cheap 'Audiosonic' running Android 4.1.1. Apparently the resolution is 800x480, and the physical smallest width of the screen is 86mm, or 3.4 inches. This means 142dpi.

Given the equation

dp = (pixels x 160) / dpi

The smallest width should be 541dp.

Now here comes the crazy part, and my question...why on earth are the sw720dp resources (layout and strings) being used by my app on this 7 inch device?!

Rob K
  • 294
  • 2
  • 10

1 Answers1

0

Check this answer and use Configuration and Display classes as explained to get screen resolution, density and layout family (normal, large, ...) to be sure about actual properties of this device. Manufacturers can decide to set a device in a different family from the one you're expecting.

How do I get the ScreenSize programmatically in android

Community
  • 1
  • 1
fasteque
  • 4,309
  • 8
  • 38
  • 50
  • This device has Android 4.1.1 though, so the 4 deprecated 'screen size buckets' should be irrelevant given that I'm providing sw600dp resources. – Rob K Sep 29 '13 at 22:02
  • More importantly, I can't understand why the sw720dp resources would EVER get chosen on a 7 inch screen. I can see why the sw600dp resources may not get used, but surely the sw720dp resources would never be a better match than any of the deprecated buckets that I've also provided? – Rob K Sep 29 '13 at 22:03
  • Did you try to get that info programmatically? – fasteque Sep 30 '13 at 06:27
  • I haven't had a chance to try that yet, but I will. Unfortunately I don't have direct access to my mate's tablet, I can only email apk files to him and wait for his feedback. Going back to what you said before...do you mean that the manufacturers can control the deprecated screen-size buckets that their devices fall into? I suppose there has to be some point at which the manufacturer is responsible for specifying some 'hard-coded' properties of the screen. – Rob K Sep 30 '13 at 10:47
  • 1
    I think that is stil a separate issue from what I'm experiencing though. As I said, the device in question is significantly narrower than 720dp, and slightly narrower than 600dp too. Surely the manufacturers can't (or shouldn't) change anything that would force a device to behave like it has a different dp width? If so, that's completely ridiculous and makes all of the Android screen size support a complete waste of time. – Rob K Sep 30 '13 at 10:48
  • I agree, that's something I've found out when I had to deal with the first Samsung Galaxy Tab 7" (http://situee.blogspot.it/2011/11/galaxytab-motorola-xoom-screen-desity.html). Anyway, that's something that don't happen very often. – fasteque Sep 30 '13 at 12:17
  • Does anyone else have some suggestions? I had a closer look at the links provided by fasteque, but they all relate to the deprecated screen size buckets. My issue relates to the swXXXdp qualifiers. Given that the device has a 7 inch screen and only 541dp smallest width (according to the equation for calculating dp), but the sw720dp resources are still being used, does that mean that the manufacturer has done something stupid that prevents the Android screen size support from working as it should on the particular device? – Rob K Oct 02 '13 at 09:35
  • Also, if I can't even rely on the built-in 'smallest width' screen support on the troublesome 7 inch device, is there any way to fix this issue? So far my only idea is to programmatically create/inflate the layouts and determine their sizing in the java code rather than in xml, but that would be a significant change to the app. – Rob K Oct 02 '13 at 09:43