Layout variant not loading(strange OR missing something)

AscySoft

Active Member
Licensed User
Longtime User
Hello All
I just get a new tablet device for testing my app, it has Android 4.0.3, and resolution of 1024 x 768(160dip=scale1)
I create a test example to demonstrate what is wrong.
A layout file with two variant(320x480 scale=1 and 480x320 scale=1)
Problem is that app always load the first layout variant(portrait) even if I turn the device into landscape position.
I just wanna know why and how to solve this.
 

Attachments

  • LayoutVarNotWorking.zip
    7.1 KB · Views: 149

AscySoft

Active Member
Licensed User
Longtime User
If you do like to create a specific tablet landscape variant then you should add a larger landscape variant.

No, I don't want to create different variants, for different devices, just the base one, modified from code(not even design scripts)

So I guess I should use designer script, but how to
use the designer script to scale the portrait variants.
?
How can I command 2 Activity to load the landscape variant?

Thanks for the quick reply.
 
Upvote 0

AscySoft

Active Member
Licensed User
Longtime User
Let me clear things up a bit
I have a large app, with meny layouts. Each layout is created for 480x320 160dip and 320x480 160dip. So each layout contains both landscape and portrait variant.
(using different code settings, I rearrange layouts elements from code)
But on larger devices, only portrait variant is loaded (now I know why).
How to load landscape when necessary?
 
Upvote 0

AscySoft

Active Member
Licensed User
Longtime User
I heard you, I must test to see if your solution is better(quicker)
But because UI elements are entirely different in very layout variant, It's a pain in the ... to reposition on screen.
As I see, the only quick solution is to broke every layout in two, one for landscape and one for portrait, and the loading it accordingly.

Maybe in the future you could find a way to tell app to load specific layout variant... don't know, to me you are a genius anyway!
:icon_clap:
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
If you do like to create a specific tablet landscape variant then you should add a larger landscape variant.
Unfortunately in that case AutoScale is no more usable.

A workaround is to define two layout files for the standard screen size one portrait and one landscape and loading the correct one according to the orientation. The you can use AutoScale.
The maintenace will be somewhat less convenient than with one layout file with just two variants.
In your example:
- save the portrat variant in one file
- save the landscape variant in a second file
and
B4X:
Sub Activity_Create(FirstTime As Boolean)
'    Activity.LoadLayout("test")
    If 100%x>100%y Then
        Label1.Text ="Landscape"
        Activity.LoadLayout("testL")
    Else
        Label1.Text ="Portrait"
        Activity.LoadLayout("testP")
    End If
    Log (Label1.Text )
    Log (GetDeviceLayoutValues )
End Sub
Attached your example modified with AutoScale (rate = 1).
You can play with the rate value to change the scale factor.

Best regards.
 

Attachments

  • LayoutVarNotWorking1.zip
    9.8 KB · Views: 148
Upvote 0

AscySoft

Active Member
Licensed User
Longtime User
Ok, I realize this is much more complex than it seems at first glance.:D
Erel, I just need to know the "inside" LoadLayout functionality in order to determine what's best form me.

You were saying something about "match score". The question is, how does LoadLayout is loading a certain layout variant? Based on what? Is there any documentation? How should I trick to load layout for landscape(if someone want that) It will be possible someday?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
This issue will be fixed. Landscape phone variant will be loaded in landscape tablets as well.

Note that AutoScaleAll can work with other variants as well.
If however you already set the views text and size to match a tablet size then you should not call AutoScaleAll as it will further increase their size. However there is no problem with creating a tablet variant and calling AutoScaleAll.
 
Upvote 0

AscySoft

Active Member
Licensed User
Longtime User
This issue will be fixed. Landscape phone variant will be loaded in landscape tablets as well.

This is good news! :sign0142:
Do you have any idea when this fix will be available?(no pressure, I just wanna know)
And, the other question: do you intend to modify LoadLayout functionality to auto-load correct variant(portrait/landscape) or let the user decide what he wants?
Thanks for your time and for your answer.
 
Upvote 0
Top