Designer Layout issue

Harris

Expert
Licensed User
Longtime User
I commented out all code relating to loading many different layouts based on old method of handling many different device sizes.

Used standard variant (480x320) to adjust my main form layout that was sized for 1024 x 600. Using the examples, all looks great on my Nexus 7 (1280 x 800) in designer and when compiled.

I then created a new variant and specific variant code (320x480) which places views accordingly in portrait mode. Fine in designer...

When compiled app ran, device in landscape position, the portrait variant was chosen by default? Rotating device wouldn't choose the landscape mode??? Removed new variant (and supporting code) and everything is fine again - but only in landscape since the portrait variant doesn't exist.
 

Kevin

Well-Known Member
Licensed User
Longtime User
I'm too tired to think deeply on this, but I wanted to mention that I have several layouts with multiple variants (and for landscape & portrait) and have noticed that some AVDs don't pick what I would have expected them to pick. As best I can tell it is because Android picks the best variant at run-time and when you take into account SCALE and not just dimensions, it helps understand why it is doing that. It picks whichever it thinks is best, irregardless of intended orientation. If my math and memory is right, divide the screen size by scale and from there you should be able to guess which variant Android will pick. To keep it simple, 480x320 scale 1.5 equates to 320x213.3333 as far as Android is concerned.

I hope this helps nudge you towards your answer. I believe it could be something like this, although I just pulled those numbers out of my ass. :) If it weren't so late and I wasn't so tired I'd try to give a more solid example. Sorry.

A more complicated method is to create a whole separate layout for each "variant" and choose it yourself through code.
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
@Kevin: A more complicated method is to create a whole separate layout for each "variant" and choose it yourself through code.

This is what I started with (many, many variants) and wish to move away from this. Your reply of Android choosing the "best" variant is what I also expected.

@Erel: I have read the tutorials many times and have followed (copied code) to understand how this works. Question is: how do I get my app to set the correct specific variant (port or land) using the standard variant at run time? I can't seem to figure this out (blind/stupid or both).

Thanks guys...
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
From: Designer Scripts Tutorial

"The system chooses the closest variant it finds. For larger tablets is might choose the portrait variant even if the tablet is in landscape orientation."


This is what I find when on Nexus 7, 1280x800 - 1.5

"I recommend you to only create a landscape version for the standard phone variant. At least when you start designing."

I have done this. What does one do after they start designing?
My app looks/works better in landscape (on tabs). However, my tester with a GS2 (800x480 - 1.5) swears it feels better in portrait - which is understandable since this is the natural way to hold a phone. One can't deny the 20 gazillion S2 and (S3) units sold... (I would prefer to support landscape only since portrait requires ALOT of repositioning views). If every app used lists only, this wouldn't be an issue...[/B]

"In most cases the general script should do the work for the larger tablets."

Does the above suggest I should create a 800x480 - 1.5 (1.0) variant to handle phones vrs tablets? Newer tabs are usually larger than 800x480 - or at least anything I wish to support.

I believe tabs look and work best in landscape mode (who watches a video in portrait?). My app is designed for a 7 inch or greater tab (or GS2 in lanscape). I expect a device to be mounted in a cradle in landscape mode and when using my app. However, by default, the Nexus7 shows the apps menu in portrait (WTF?).

Give me one GOOD reason why I should support portrait. Geez, if it wasn't enough supporting multiple screen sizes and scales, we must deal with oriantaion...

:sign0089:
 
Upvote 0
Top