Android Question Set Portrait and Landscape Variant in Designer??

ilan

Expert
Licensed User
Longtime User
Hi,

after 3 years and (about 50 apps) i will ask this silly question :oops:.

i am making a new app and i would like to be able to use it in portrait and landscape.

i want to put the views a little bit different when i use it in landscape mode not like it is in portrait since i have more place in the x axis.

so i created 2 different variants 1920*1080 & 1080*1920
this is the phone i am using (galaxy s5)

the question is do i need to set all available variants or it is enough to set 2 variants 1 for portrait and 1 for landscape?

i define the views position and size in script variant and not in general variant.
is this correct?

another question if i add new views programmatically can i say if landscape then do this else do this...?

if yes how?

thanx, ilan
 

LucaMs

Expert
Licensed User
Longtime User
or it is enough to set 2 variants 1 for portrait and 1 for landscape?
I think yes.


i define the views position and size in script variant and not in general variant.
is this correct?
YES!


if i add new views programmatically can i say if landscape
You should test the orientation:
[Globals]
Private Landscape As Boolean

Activity_Create
Landscape = (100%x > 100%y)


If Landscape Then
' resize/move new views
Else
' resize/move new views
End If
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
Note that these numbers without the scale are meaningless. Make sure to use a "normalized variant" (an equivalent variant with a scale of 1.0).

sorry but i dont understand you, i always used on my apps only 1 variant portrait or landscape now i would like to use both

but views should not be in the same location when i rotate my phone

sc1.jpg


so what i do i create 2 script variant with resolution 1920*1080 & 1080*1920 scale 3.0!

but i disable 'Autoscaleall and every view i set his position and size with %

like view1.left = 0
view1.height = 5%y ...

so no need for autoscaleall but what i would like to know is if i set 2 variants 1 for portrait and 1 for landscape will all devices that are in landscape mode get the
variant i set with 1920*1080? or could they get the portrait variant and views would not be like i wanted them to be?? because that device has a different resolution that is not defined.

could you please explain a little bit more? thank you for your patience @Erel
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
thanx a lot, it is much easier then i thought.
i am very impressed, i just need to find a way how to store my data in activity_pause because the rotation restart the activity.

thanx a lot @LucaMs :)
 
Upvote 0
Top