0

Wondering if anyone has ran in to this.

I have created layout folders with 5 resource qualifiers.

  • sw320dp
  • sw480dp
  • sw600dp
  • sw720dp
  • sw800dp

I also have 5 drawable folders with resource qualifiers from mdpi through xxxhdpi.

My goal is to have my application function on all devices (minus small) with smallest width of 320 and any density.

I am 90% of the way there and have ran in to an issue which I have been unable to resolve. My guess is that I have an issue with resource qualifier precedence , but that is only a guess.

The issue I am running in to is this. I can double-click on ANY of my layouts in any of the different layout folders and it will bring up the layout using an appropriate device within Android studio designer given the sw<n>dp layout that I selected. For example, if I double-click on my main_activity layout that is in the sw600dp folder, it opens using the 7" tablet and everything is good. This holds true for every layout I have in every layout folder, with the exception of ONE layout within my layout-sw480dp folder.

When this particular layout is opened, it opens up in Portrait mode via the Nexus 4, when it should have launched one of the sw480 devices instead. If we look at the specs of the Nexus 4, it is as follows.

768 x 1280 / hdpi

So, this means that the smallest width of this device would be 768 / 2 = 384, which falls in to the sw320dp bucket.

If I then select one of the sw480dp devices, such as the Nexus 6p, which has the following specs, 1440 x 2560 560dpi which in turn has a smallest screen width of 1440 / 3 = 480, it opens using a layout in the sw320dp folder.

Again, this is the ONLY layout file that is doing this out of ALL of them.

If anybody has any suggestions or has ran across this type behavior in the past, I would love to hear what you did.

R. Zagórski
  • 20,020
  • 5
  • 65
  • 90
bboursaw73
  • 1,128
  • 2
  • 13
  • 26
  • HDPI is not 2x, it's 1.5x. So the sw of the Nexus 4 ist 512dp. – MatF Jul 10 '16 at 08:33
  • see my answer [here](http://stackoverflow.com/questions/36820746/how-to-design-any-screen-size-and-density-in-androidmulti-screen-for-mobiles/36821546#36821546) – mehrdad khosravi Jul 10 '16 at 08:46
  • Correct, typo on my part. This has gotten a bit more odd. I have attempted to simplify things by moving to a single set of layout files for my app (no qualifiers). I believe I should be able to do this since my layouts that I had been putting in each of the different layout-qualifier folders were identical. I do have some size and placement differences that need to be accounted for given screen size and density, so for that I am still using my values-swdp- folders. – bboursaw73 Jul 10 '16 at 09:25
  • Update. The issue seems to be that when selecting the 5x/6/6p devices in Android studio, they are trying (but failing) to use the values-sw320dp-hdpi folder, which is wrong for all three. I have come to this conclusion because the layout in question is getting a value for textsize of 99 which I specifically put in my hdpi version to see if that is actually what was getting pulled. – bboursaw73 Jul 10 '16 at 09:35

0 Answers0