Android Question Space icon apart based on screen size

aaronk

Well-Known Member
Licensed User
Longtime User
Hello,

I am trying to space 4 images along the bottom of the screen in the designer but I can't work out how to space them apart evenly along the bottom of the screen.

I don't want them touching each other and need them spaced evenly no matter what screen size it's running on.

Here is a sample on what I am trying to do:

sample.png


The only way I have worked out so far is the following code but not sure if there is a better way in doing this?

B4X:
icon1.HorizontalCenter = 15%x
icon2.HorizontalCenter = 38%x
icon3.HorizontalCenter = 61%x
icon4.HorizontalCenter = 85%x
 

mangojack

Expert
Licensed User
Longtime User
Here's another option .. allowing for resizing icons. But whether it is better ?

B4X:
Dim xSize As Int = Icon1.Width /2
   Dim Xpos As Int = 100%x / 8

   Icon1.Left = Xpos  - xSize
   Icon2.Left = Xpos * 3 - xSize
   Icon3.Left = Xpos * 5 - xSize
   Icon4.Left = Xpos * 7 - xSize

Have you reread offered suggestions in your previous thread regarding something similar .. ?
Code to space buttons apart
 
Last edited:
Upvote 0
Top