Activity Orientation Issue

FifersLost

Member
Licensed User
Longtime User
Just trying out B4A trial before splashing on the enterpise version. Very impressed thus far but have had a small problem. I have designed the form (activity) on an emulated device with resolution 480 x 800 in portrait mode. However, when I deploy to the physical device (a Samsung Galaxy S2), it appears to display as if rotated by 90 degrees (i.e. 800 x 480) and won't fit on the screen. Probably something daft, but can anyone provide a hint before I have to redesign again on an emulator with 800 x 480 screen. Cheers.
 

FifersLost

Member
Licensed User
Longtime User
Thanks Erel. I suspect I didn't explain properly. It looks fine in the emulator in portrait mode (scale is correct) but when installed on the actual device, in portrait mode, it looks like it's trying to display a landscape view i.e. it won't fit on the screen.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
The scale parameter is the most important part of the display configuration.
For phones such as yours you can use the standard emulator display - 320x480, scale=1 (160 dpi).
Or you can create a custom one matching your device which is - 480x800, scale=1.5 (240 dpi). This resolution is equivalent to: 320x533, scale = 1.
 
Upvote 0

fraxinus

Member
Licensed User
Longtime User
Have you chosen Portrait mode in Project - Orientations Supported - portrait
And in the designer variant set to 480 x 800
 
Upvote 0

FifersLost

Member
Licensed User
Longtime User
Check on all these points. I set up an EMU device at 480x800 and 240 density (avd.png). Created a sample form on said device (emu_display.png) and then compiled and installed on the physical device (gs2_display.png). I'm def confused here. Thanks for you help.
 

Attachments

  • avd_settings.jpg
    avd_settings.jpg
    7.6 KB · Views: 200
  • emu_display.jpg
    emu_display.jpg
    8.2 KB · Views: 174
  • gs2_display.png
    gs2_display.png
    1.2 KB · Views: 189
Upvote 0

FifersLost

Member
Licensed User
Longtime User
I'm getting some strange results just using the emulator. I thought it varied dependent on whether the designer was open when the compile-deploy sequence (CTRL-F5) was run, but it doesn't seem consistent. Image names in zip describe whether designer was open or closed when compiled. Added messagebox for second set of images. Project is same, form layout is same in all circumstances. Bizarre.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Your layout is too large. See the width value of the label:
SS-2011.06.25-17.46.05.png


There might be a problem with the emulator itself if it returns inconsistent values. I recommend you to create a new emulator instance and use the standard values (320x480 scale=1, dpi=160). It will match more or less the dimensions of a higher resolution device like your Galaxy S2.
 
Upvote 0

kickaha

Well-Known Member
Licensed User
Longtime User
In all your layouts, the views are often wider than the screen size (eg 480_800_all has a label 570 wide and is positioned 45 from the left edge, so you will cut off 135 pixels of it).

I think if you go through the layouts and position the views to be within the screen boundaries your problems will be solved.

Edit: beaten by Erel
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
In the Designer you make the layout for a specific width and height and associate a scale with it. The scale is used to match that layout to the device screen on which it is to be displayed by multiplying the view coordinates by the device scale and dividing by the layout scale. Nothing more, that's all the adjustment that is made. If there are multiple layouts in a layout file B4A will choose what it think is the closest match and then adjust the coordinates for display as above.

For instance I have the Designer open and am making a 320 x 480 scale 1 layout. The Designer is actually running on my 480 x 800 scale 1.5 device. I have set a Panel on the activity with coordinates 10, 10, 300, 400 so I intend it to almost fill the screen. On my device it is being displayed by the Designer with coordinates 15, 15, 450, 600 because it has scaled the coordinates as I described above so it looks the same as it would on the smaller lower scale screen.

It really is quite simple. At runtime the layout that best matches the screen is chosen and the coordinates scaled by DeviceScale/LayoutScale. That's all that happens.
 
Last edited:
Upvote 0
Top