1

I want to use separate values for each density, so I created different values folders for each one,

values
values-ldpi
values-mdpi
values-hdpi
values-xhdpi
values-xxhdpi

in each of the strings.xml file I wrote the density (for values-xxhdpi i have a string with the text "xxhdpi"), but when I run this on GS4, I get the "mdpi" string,

I also did create separate layout folders, but always taking layout-mdpi density

any clue of what might be going on ?

TootsieRockNRoll
  • 3,218
  • 2
  • 25
  • 50

1 Answers1

1

It looks a bit funny to me to define layouts according to density and not size. Drawable and other similar resources depend on density, but layouts depend on size.

See here : http://developer.android.com/guide/practices/screens_support.html

For values, you could give it a try with values-normal, values-large, etc.

I write this although what you did is supposed to work according to this thread : https://stackoverflow.com/a/9639280/693752

Also, this resource is interesting to you : http://developer.android.com/guide/topics/resources/providing-resources.html#BestMatch

---- UPDATE ----

Look at this answer from GodFather : https://stackoverflow.com/a/20521720/693752

(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.)

Community
  • 1
  • 1
Snicolas
  • 37,840
  • 15
  • 114
  • 173
  • thank you very much for your time, although I read that S4 is of a NORMAL screen, then again so is GALAXY ACE, so the problem still persists, how can I differentiate between them ? – TootsieRockNRoll Apr 18 '14 at 14:52
  • I can't see a use case where you need to change strings displayed according to density, on size yes, but density, it really bugs me. – Snicolas Apr 18 '14 at 14:58
  • I was trying to make an XXHDPI layout, but it ended up using an MDPI one, so I used strings to see where the problem is, kind of a debug trick that's all – TootsieRockNRoll Apr 18 '14 at 15:01
  • Again, I can't see how a layout can depend on density. It should depend on size. – Snicolas Apr 18 '14 at 15:10
  • hmm I see, so here is a straight question: how can I differentiate between layouts of a galaxy ace, and a galaxy s4 (besides working with mdpi and xxhdpi, I have no clue how to do it), thanks a lot ! – TootsieRockNRoll Apr 18 '14 at 15:15
  • If both devices have same size (or size range) then trying to distinguish them will lead you to some over-specific layouting. What are you gonna do next, have a different layout for each single Android phone on earth. That might take time. If there is really a difference in size between the 2, the there must be a better qualifier than just "normal", maybe something like "sw540dp", something like this. – Snicolas Apr 18 '14 at 15:31