Android Question Layout fine in designer, but not on device

Arf

Active Member
Licensed User
I've got a layout that includes an ImageView which shows a background picture and I draw graphs over it.
I have 2 variants in the designer only - generic 7" portrait and the same in landscape (960*600), scale 1.
In the designer I have width and height settings for the panel as 601x680.

In the portrait designer script I set the ImageView for width = 100%x and adjust the height and position to maintain aspect ratio.

In landscape I set it for height = 100%y and adjust the width and position to maintain aspect ratio.

All works fine on 7" tablet. I've got AutoScale on. If I connect my smaller samsung S3 phone to the Designer and run the designer script, it displays fine on the phone.

However when I actually run the app on the phone, when the phone is horizontal, the ImageView width is as wide or a little wider than the screen, and vertically I can see less than half of it.

The phone resolution is 800*480 in landscape, 1.5 (240dpi)

Can't figure out why, the scripts for that bit are dead simple. I named the imageView Axes.
Portrait:
B4X:
Axes.Width = 100%x
Axes.Height = Axes.Width*528/460
Landscape:
B4X:
Axes.Height = 100%y
Axes.Width = Axes.Height*460/528
Is it perhaps something to do with the ImageView size settings in the designer?
 

klaus

Expert
Licensed User
Axes.Height = Axes.Width*528/460
and
Axes.Height = Axes.Width * 528dip / 460dip
will give the same result.
Do you also adjust the Left and Top properties ?

Can you post a small project showing thw problem.
 

Arf

Active Member
Licensed User
I don't adjust LEFT and TOP, but the anchor points in the designer for Axes is left, top.
I tried SetTopAndBottom(0%y, 100%y) instead of just setting height but the outcome was the same.

I have attached a project with just this element in it.
Thanks guys.
 

Attachments

klaus

Expert
Licensed User
Attached a modified version.
It seems that in landscape the program doesn't read the correct layout.
Instead of calculating the dimensions in the specific layout sections I moved them to the 'All variants' section, testing wether the device is in portrait or landscape.
 

Attachments

Arf

Active Member
Licensed User
Thanks Klaus, I'll check it out.

Do you think it's something to do with B4A that is stoping the correct layout being picked up, or something to do with the device?
It works fine on all the larger devices I've tried it on, just not the galaxy phone.
 

klaus

Expert
Licensed User
Do you think it's something to do with B4A ...
I don't know.
Another point in your layout.
You set AutoScaleRate after AutoScaleAll, you should invert them, set AutoScaleRate before AutoScaleAll.
But event with this change it didn't solve your problem, I saw it too on my Sony xperia z1.
 
  • Like
Reactions: Arf

Arf

Active Member
Licensed User
I have swapped the Scale Rate and Scale All is in your example now.
It is working now on all my devices, thanks for the help :)
 
Top