I know that this behaviour is not expected nor standard, but I'm curous whether it can be achieved. Google also realized that the normal-large-xlarge scheme is not the best one, so it's deprecated from Android 3.2. (layout-swXXXdp would be the best choice for me)
However, there are devices under 3.2 which I have to support, and can misbehave because this system.
Main problem:
Galaxy Note 1 and Galaxy tab 1 (and other devices with same specs) choose the resources from the same layout-large
folder. But reasonably I need to make different layouts under 7 inch and above 7inch screens. I know that I could make a seperate folder for "exception devices" (like layout-large-xhdpi-1280x800 as mentioned here), but then I would have to maintain several almost (or exact) same xml files in different folders just because these certain devices.
So the goal would be to maintain only one xml package (folder) for under-7inch-devices, and one for above-7inch devices. I know that there are tricks such as:
- naming the xml-s differently (main.xml and main-large.xml), and decide in code which to choose, but even devices can't decide about themselves from code, how large are them exactly (for example 7 inch tablets can give back from 6.8 to 7.8 inch scale). Also, I would like to use the more "androidy" way with resource folders.
- maintain the exception folders as i mentioned.
layout
,layout-large
,layout-specifictags1
,layout-specifictags2
and the list can widen. Also specifictags1, tags2 and normal has the exact same xml files, but needed for devices not to choose from thelayout-large
. The whole reason is to avoid this. - (EDIT) An idea of using aliases came up by @Joe Malin. Unfortunatly I can't make an alias named main.xml in
layout-large-xhdpi-1280x800
that refers to main.xml inlayout
, because it refers to self then (making infinite loop). So i would have to maintain a fakemain.xml inlayout-large-xhdpi-1280x800
that refers to main.xml which only exists inlayout
. But then i also need a fakemain.xml inlayout
, because then i don't have to care about the layout from code and use only the fakemain.xml which is an alias. However this solution still could work, but is not working in practice, unfortunatly. If I have a a fakemain.xml inlayout
,layout-large
andlayout-large-xhdpi-1280x800
for galaxy note, then the alias points to thelayout-large
one, and I achieved nothing by using the alias.
Question:
layout-sw600dp concept would grant me the best and needed behaviour, but it's not supported under API level 13.
- Is there a way to force a device to choose from this folder, or to write over its variable (with java reflection? - I know that's pretty bad) to behave like normal screen not large?
- Is there a way to maintain only two xml package (folder):
- one for under-7inch-devices,
- and one for above-7inch devices.