Android Question Layout fine in designer, but not on device

Arf

Well-Known Member
Licensed User
Longtime 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?
 

Arf

Well-Known Member
Licensed User
Longtime 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

  • examp.zip
    26.3 KB · Views: 131
Upvote 0

klaus

Expert
Licensed User
Longtime 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

  • examp1.zip
    26.5 KB · Views: 136
Upvote 0

Arf

Well-Known Member
Licensed User
Longtime 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.
 
Upvote 0

klaus

Expert
Licensed User
Longtime 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
Upvote 0

Arf

Well-Known Member
Licensed User
Longtime 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 :)
 
Upvote 0
Top