Busman
Busman

Reputation: 635

Android - layout-large not being selected for Samsung Galaxy S8+

In my app, I support multiple screens to a reasonable extent as per the guidelines here and here. However, the S8+ seems to be taking the layout-normal layout instead of layout-large. I remember reading that it could be due to its odd aspect ratio (18.5:9) when its setting for "use fullscreen" or something is enabled. It seems with or without this setting the result is the same (uses normal layout). I suspect there are other phones that will have this issue.

Also, interestingly, I made a generic device definition in Android Studio of that phone, with it's 2960x1440, 6.2" screen to preview the screen and Android automatically reclassified it as a tablet (and forces it to use the large layout in the preview). This leads me to believe that it would do the same at runtime on a device, but it would appear it doesn't.

How can I set my app to have these phones (perhaps those with these...problematic...aspect ratios) use the large layout it was supposed to?

Upvotes: 0

Views: 737

Answers (1)

C B J
C B J

Reputation: 1868

As mentioned in the comment by @CommonsWare, it would be better to use dp size qualifiers, however to shed a little light on why your problem happens:

The old size qualifiers are size "buckets", they represent a range of sizes and aren't very precise. So the S8+ falls into the normal size bucket on the device (probably due to the size the device is reporting), but large on the emulator (which seems suspect to me).

If you look closely at the resource qualifier definitions listed here Providing Resources you will notice the definitions for screen size are a bit vague.. taking a unit dp to be 1/160 inch.. the screen sizes they describe are "approximately":

small: 2" x 2.6" medium: 2" x 2.9" large: 3" x 4" xlarge: 4.5" x 6"

Note that all of these sizes are surprisingly small. In reality the device manufacturer decides the bucket it falls into, which is very likely why your S8+ reports "normal" and the emulator is a tablet.. by the table above, it would be.

Essentially I recommend you use the "smallest width" qualifier. You can find some hints around the values you might want on the same page linked above.

Upvotes: 1

Related Questions