Android Question Arranging a series of imageviews in a panel

Sanxion

Active Member
Licensed User
Longtime User
Hi all

I am attempting to arrange 12 imageviews in a panel and am receiving some unexpected results.

This is the designer script I am using:

B4X:
ImageView1.SetLeftAndRight(5%x,30%x)
ImageView1.SetTopAndBottom(5%x,25%x)
ImageView2.SetLeftAndRight(35%x,60%x)
ImageView2.SetTopAndBottom(5%x,25%x)
ImageView3.SetLeftAndRight(65%x,90%x)
ImageView3.SetTopAndBottom(5%x,25%x)

ImageView4.SetLeftAndRight(5%x,30%x)
ImageView4.SetTopAndBottom(30%x,50%x)
ImageView5.SetLeftAndRight(35%x,60%x)
ImageView5.SetTopAndBottom(30%x,50%x)
ImageView6.SetLeftAndRight(65%x,90%x)
ImageView6.SetTopAndBottom(30%x,50%x)

ImageView7.SetLeftAndRight(5%x,30%x)
ImageView7.SetTopAndBottom(55%x,75%x)
ImageView8.SetLeftAndRight(35%x,60%x)
ImageView8.SetTopAndBottom(55%x,75%x)
ImageView9.SetLeftAndRight(65%x,90%x)
ImageView9.SetTopAndBottom(55%x,75%x)

ImageView10.SetLeftAndRight(5%x,30%x)
ImageView10.SetTopAndBottom(80%x,100%x)
ImageView11.SetLeftAndRight(35%x,60%x)
ImageView11.SetTopAndBottom(80%x,100%x)
ImageView12.SetLeftAndRight(65%x,90%x)
ImageView12.SetTopAndBottom(80%x,100%x)

This is how it appears on a 10" and 6" device in addition to how it appears in the designer:

The 10" appears to be fine but the 6" version does not fill the screen - nor does it fill the panel in the designer.

Any ideas what I am doing wrong?

Thanks
 

Attachments

  • 10inch.PNG
    10inch.PNG
    147.9 KB · Views: 262
  • 6inch.PNG
    6inch.PNG
    58.7 KB · Views: 247
  • Designer.PNG
    Designer.PNG
    20 KB · Views: 256

klaus

Expert
Licensed User
Longtime User
What are the dimensions of the Panel?
You are using only %x values also for the vertical dimensions?
If you have different width / height ratios you get what you see.
You should use %x and %y values, but respecting the aspect ratio.
 
Last edited:
Upvote 0

Sanxion

Active Member
Licensed User
Longtime User
T
What are the dimensions of the Panel?
You are using only %x values also for the vertical dimensions?
If you have different width / height ratios you get what you see.
You should use %x and %y values, but respecting the aspect ratio.
Thank-you Klaus.
That was my mistake, not using the %y values for the vertical dimensions.
Can I ask, is the way I am doing this - using the designer script with %x/%y values - the best way?
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Can I ask, is the way I am doing this - using the designer script with %x/%y values - the best way?
It depends on how you are doing it.
Yes, if don't care about the width / height ratio of the images.
No, if you want to keep the width / height ratio of the images.
In this case you need to calculate the width and height of the images according to the screen size and space between the imahes and then position them.
 
Upvote 0
Top