3

Problem:

I am testing my app using the Eclipse/ADT bundle. On an AVD created to emulate the Galaxy S4 (a device defined as being "normal" in size) the OS is selecting the XML files from the values-large folder.

The Android operating system is ignoring all other values folders I have defined in an attempt to differentiate the S4 from tablets.

Given the following folders, it selects the values-large folder for the S4:

values-large
values-sw720dp
values
values-normal-hdpi
values-normal-mdpi
values-normal-xhdpi
values-normal-xxhdpi
values-normal

The problem is that I have Master/Detail (ListFragment/Detail-Fragment) two-fragment display that only displays correctly on large screens (tablets). It does not display correctly on the S4, because of the device's size. On a device smaller than 6" wide, the icons end up getting displayed on top of the text, instead of to the right of the text. The only difference is with the S4 in landscape orientation.

The S4 is the ONLY normal sized device that can show the two-pane layout in landscape orientation. The Nexus 4 and others cannot. In landscape the extra density of the S4 is what makes it work.

I also don't want the S4 to use the dimens.xml file that is in the values-large directory.

Questions:

Is this normal/expected behavior? Does the OS classify the S4 as a "large" device? The OS has ignored every other folder name I have tried to use to target the S4. So, it prefers the pre 3.2 names over the newer ones.

In other words, when I attempt to use the newer folder names, like values-sw720dp, the OS still chooses the large folder.

I have two AVDs. One I created to match the specs of the S4. The other is the Sony Xperia Z1, that has the same specs and is available when you install the Sony SDK. Both AVDs are setup with size=normal. I have checked each to makes certain there is no mistake in their setup.

Thanks.

EDIT

I have a new LG G2, which is similar to the S4 in size and density. It does NOT use the values-large directory. I think it is using values-normal-xxhdpi, but need to run more tests (changing dimension values in the dimens.xml) to see what directory it is choosing.

Rick Falck
  • 1,778
  • 3
  • 15
  • 19
  • Your question is rather confusing as written. What is the *final, complete* set of resource directories that contain your desired resource? – CommonsWare Dec 10 '13 at 01:21
  • @CommonsWare, I have edited it to make it clearer. Did it work? Thanks. – Rick Falck Dec 11 '13 at 06:11
  • You are attempting to have resource directories that have both screen size and screen density qualifiers. The results of that are unlikely to be what you want. – CommonsWare Dec 11 '13 at 12:46
  • the Nexus 5 is basically the same as the S4, so it's not " the ONLY normal sized device that can show the two-pane layout" in your example – whyoz Feb 05 '14 at 19:18

3 Answers3

2
  1. values-large etc are deprecated with android 3.2 (?). It was replaced with things like values-sw720dp and there is basically not a single device out there running android 3.0 or 3.1. Any device running android 2.x is most likely a medium sized phone.
    This means, there is no need of using this old qualifiers.

  2. values-sw720dp means, smallest width = 720dp I doubt, your S4 is that wide.
    You should use a qualifier like values-w720dp, which means width = 720dp where width depends on your current orientation.
    It's way better than relaying on port or land combination because it shows the two pane layout for large displays having 720dp width in portrait orientation too.

flx
  • 14,146
  • 11
  • 55
  • 70
  • Thanks, but quoting facts I already know doesn't help explain why the S4 (running API 16+ 4.1.2+) is being resolved to the values-large folder when I also tried many others with different swxxx and wxxx names. Right now, I would like to keep the large folder for older tablets and keep the S4 from resolving to that folder. – Rick Falck Dec 10 '13 at 02:35
  • The Sony Xperia Z1 AVD does the same thing as the S4 AVD. Is there an undocumented feature that would cause a normal sized device with xxhdpi to get classified as a large device? – Rick Falck Dec 10 '13 at 02:42
1

Master/Detail two-pane layout for large screens (any orientation)

That seems fine. The implication is that you will use this for -xlarge as well as -large.

and medium screens with high dpi in landscape orientation

First, I do not know what "medium screens" are, as that term is not used in Android development.

Second, I have no idea why you think this would be appropriate. Screen density should not impact the decision of whether to show one or two panes. I would be interested to know applications, written by experts, you see taking this approach.

At first I thought it was the second folder (sw720dp) causing the problem

Note that you have not stated what the problem is.

The Sony Xperia Z1 AVD

I am not aware that SONY distributes emulator images for their devices.

does the same thing as the S4 AVD

I am not aware that Samsung distributes emulator images for their devices.

Is there a values folder I can use to make the Galaxy S4 not choose Master/Detail at all, but still allow tablets to use it?

Ignoring your "medium screens with high dpi in landscape orientation", use -large or -xlarge for tablets. The Samsung Galaxy S4 will not use -large or -xlarge resources, as it is a -normal device. This was confirmed using both the GT-I9500 and the SGH-I337 versions of this particular model.

Is there a way I can make it use Master/Detail for the S4 only when in landscape?

You can use -normal-land to identify -normal devices in the -land orientation. Note that screen size (-normal) is a bit of a fuzzy match, in that Android considers that valid for devices in that size class or larger. Hence, -normal-land would be used by -large-land and -xlarge-land devices as well, in the absence of better matches.

(Note that density qualifiers are even fuzzier -- -mdpi will be used for any device density, in the absence of a better match, as density qualifiers are designed to be used only on drawable directories, where Android can apply resampling algorithms. Using density qualifiers on anything other than drawables and maybe dimension resources is a code smell.)

Personally, I would not use a dual-pane strategy for -normal-land devices, as -normal goes all the way down to 3" diagonal.

This is all in the Eclipse/ADT bundle using the emulator.

My guess is that this is where your problems are coming in.

Unless you downloaded something from a device manufacturer (e.g., Amazon with their emulator images for the Kindle Fire series), NEVER say that you have a "Sony Xperia Z1 AVD" or a "S4 AVD". You are lying to us and, worse, you are lying to yourself. At best, you have an emulator image that you think that you have configured to match the specifications of those devices. However:

  • That assumes you got the configuration correct
  • That assumes that the device manufacturer has not changed the behavior of their device at the firmware level
  • That assumes there are no emulator bugs

You are certainly welcome to say that you are testing things on -normal -hdpi emulators, or the like, as those are things that you directly control via the Device Definitions tab of the AVD Manager.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Thanks! I downloaded the Sony SDK from: http://developer.sonymobile.com/knowledge-base/sony-add-on-sdk/install-the-sony-add-on-sdk/. It has the Xperia AVDs. Medium = normal. Problem: The OS is resolving to the values-large folder for the S4. – Rick Falck Dec 11 '13 at 19:47
  • are you saying that the OS should see the S4 as a normal size device? That is the problem! It ignores all other folder names I have tried, and always goes to the large folder. – Rick Falck Dec 11 '13 at 19:54
  • @RickFalck: "are you saying that the OS should see the S4 as a normal size device?" -- yes. "It ignores all other folder names I have tried, and always goes to the large folder." -- what actual S4 have you tested on? Again, I tried both the GT-I9500 and the SGH-I337 versions of the S4, and they both use `-normal` resources. – CommonsWare Dec 11 '13 at 20:02
  • YES!!! THAT'S WHAT I AM SAYING!!!!!!!!!!!!! I am using AVDs, in Eclipse/ADT. Do you know what the AVD is? I don't know how to state it any more clearly that I am NOT USING REAL PHONES!!! I AM USING AVDs IN THE EMULATOR!!!! According to what you just said, your real S4 devices are resolving to the values-normal directory. – Rick Falck Dec 11 '13 at 20:45
  • How can I make the AVDs work like a real device?? AVD = Android Virtual Device – Rick Falck Dec 11 '13 at 20:54
  • @RickFalck: "YES!!! THAT'S WHAT I AM SAYING" -- please point out where you used the term "AVD" in "The OS is resolving to the values-large folder for the S4" or in "are you saying that the OS should see the S4 as a normal size device?". "How can I make the AVDs work like a real device?" -- generally speaking, you don't, unless the manufacturer has specifically supplied an emulator image (ideal) or a device definition. You make the emulator work like the emulator. – CommonsWare Dec 11 '13 at 21:01
  • In my original post, above the first EDIT and "Thanks" I said "This is all in the Eclipse/ADT bundle using the emulator." – Rick Falck Dec 11 '13 at 21:17
  • please help. You say that your real S4 devices don't resolve to the "-large" folder? Why would it be different using an AVD of an S4? Thanks! – Rick Falck Dec 12 '13 at 21:10
  • @RickFalck: Perhaps your "AVD of an S4" is not set up to be `-normal`. Screen size is a drop-down in the Device Definitions tab. – CommonsWare Dec 12 '13 at 21:13
  • I setup the S4 as: Screen Size (in): 4.9", Resolution (px): (1080x1920), size: normal, Screen Ratio: notlong, Density: xxhdpi. The Sony Xperia Z1 is the same, except it's set as 5". Should I rewrite my initial question to be clearer? I don't need to mention the whole master/detail thing. Thanks. – Rick Falck Dec 12 '13 at 22:06
  • @RickFalck: Then you are probably hitting a limitation in the emulator. Not a lot that you can do about that. – CommonsWare Dec 12 '13 at 23:00
  • If so, can you PLEASE look at my other unanswered question "Does Android ever use the drawable-xxhpdi folder? here: http://stackoverflow.com/questions/20112596/drawable-xxxx-eclipse-versus-avd – Rick Falck Dec 13 '13 at 04:58
  • 1
    bottom line... even though I think I did everything right in setting up the AVDs for testing a "normal" sized xxhdpi device, it is using the values-large folder, and I cannot figure out if this is a bug in the emulator code or is how the OS will work on real devices. I believe I have done everything I can do on my end. So, either our testing tools are broken and can't be used to test on these AVDs, or this is how it's supposed to work, and you are wrong that it should select another folder. So far, I think you have treated me like I'm dumb and doing something wrong @CommonsWare. – Rick Falck Dec 13 '13 at 20:26
  • @RickFalck: You are welcome to test on a real S4, one that you purchase or via a virtual testing lab, like Samsung's. Or you can read other posts of how people have set up their S4 emulators, like this one: http://stackoverflow.com/questions/18974545/creating-galaxy-s4-emulator – CommonsWare Dec 13 '13 at 20:35
  • @RickFalck: My apologies, I did not pay close enough attention to the screenshot. You'll simply have to buy or borrow an S4, or not worry about the S4. The device `Configuration` (e.g., `getResources().getConfiguration()` from your `Activity)` returns a value for `screenLayout` with the `SCREENLAYOUT_SIZE_NORMAL` bit set (tested on the GT-I9500, as a follow-on to the tests I did previously). – CommonsWare Dec 13 '13 at 20:59
  • OK, it's not using the large folder on my real LG G2. – Rick Falck Dec 13 '13 at 23:49
  • @RickFalck: That's actually a fine example of another emulator limitation -- device manufacturers can do what they want. The G2 has a 5.2" display. According to the official guidance from Google, that should be `-large`. However, it's up to the manufacturers to choose their size bucket, based upon their own tests (e.g., to see how popular apps look). LG chose `-normal`, which is not terribly shocking, but also is not quite what one might expect. The emulator, up through perhaps WXGA, should give you a general idea what your app will look like, but hardware is the real test. – CommonsWare Dec 13 '13 at 23:53
  • Making it impossible to rely on the development tools for "supporting multiple screens". According to my notes, 3" - 4.7" is normal and 5" - 7" is large. So, I didn't think it was abnormal for it to choose the large folder. – Rick Falck Dec 14 '13 at 02:20
0

After reading your comments, I noticed you said you said the Galaxy S4 screen size you defined was 4.9"? All the specs I've seen say it's 5" which will actually change the size in Device definitions from "normal" to "large" once you correctly set the S4 and Nexus 5 to 5".

Edit the Galaxy S4 emulator's definitions to 5" so you have the right screen size, it will auto-change the size to large, so you will need to decide if you need to switch it to normal then go from there. Also, for those wondering, once that avd starts, it does say that it's pulling from the sw480dp folder, so in your case, you would need a new folder:

values-sw480dp or to eliminate large devices in this bucket, values-normal-sw480dp

whyoz
  • 5,168
  • 47
  • 53