Testing for Width and Height of Current Layout...

sconcequence

Member
Licensed User
Longtime User
I am trying to test for the width of the current layout based on orientation. When I use the following code, I get different results than expected.

layoutVal = GetDeviceLayoutValues

If layoutVal.Width = 480 Then
...
Else If layoutVal.Width = 800 Then
...
End If

The dimensions of the views, according to the designer, are 320x480 and 480x320, but when I use layoutVal.Width with this code, the width for the vertical orientation is 800, and the width for the horizontal orientation is 480. How do I test for the actual layout dimensions being used?

--
 

sconcequence

Member
Licensed User
Longtime User
Getting Values Without Loading Layout in Activity...

Is there a way to get these values without having to have Activity or ScrollView load the layout? I have a ScrollView that loads the layout, and it needs to be initialized with values from the layout before loading the layout itself.

Combining a ScrollView with an Activity.LoadLayout loading the same layout is a recipe for disaster.

--
 
Upvote 0

sconcequence

Member
Licensed User
Longtime User
I've already tried using GetDeviceLayoutValues...

I've already used GetDeviceLayoutValues as evidenced by my first post. It is not what I want. I want to get the layout values or name directly as it is in the Designer based on the current orientation.

--
 
Upvote 0

sconcequence

Member
Licensed User
Longtime User
Temporary Activity Variable...

From the way I see it, I need a temporary Activity object to load my "Main" layout while capturing the LayoutValues from it before actually loading "Main" from my ScrollView object.

If I were to use a temporary Panel object, I'd like some way of creating, then destroying it.

However, whenever I declare a variable of type Activity, try to initialize it and .LoadLayout, I get a "cannot find symbol : constructor ActivityWrapper()" error.

How do I accomplish this? Thanks.

--
 
Last edited:
Upvote 0

stevel05

Expert
Licensed User
Longtime User
I'm not exactly sure what you are trying to achieve, but I'll take a guess, and apologize if I get it wrong.

If you are trying to limit the size of the scroll view, regardless of the size of the activity, then you can set up a panel within the designer and add the scroll view to that.

The reported activity size will always be the size of the screen that is available.
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
The dimensions of the views, according to the designer, are 320x480 and 480x320, but when I use layoutVal.Width with this code, the width for the vertical orientation is 800, and the width for the horizontal orientation is 480. How do I test for the actual layout dimensions being used?
You are probably not taking account of the scaling of the display. GetDeviceLayoutValues tells you the size in physical pixels of the display and it's logical dpi, used to calcaulate the scaling. A Designer layout of 320 x 480 scale 1 (160 dpi) will display as 480 x 800 on a display with a scaling of 1.5 (240 dpi)
 
Upvote 0
Top