Android Question [SOLVED] Center control between two other controls

techknight

Well-Known Member
Licensed User
Longtime User
My math skills absolutely suck. Apparently.

I am wracking my brain trying to figure out how to position a control in the center between two other controls.

For example I have 4 labels. Two at the top of the screen next to each other, (height 50, height 120) one at the bottom of the screen.

Layout:
1
2

<need 3 here>

4

How?
 

techknight

Well-Known Member
Licensed User
Longtime User
designer script. Trying to adapt to different screen sizes so the controls dont overlap.

But I will need to do this programatically as well with some other controls
 
Upvote 0

Jeffrey Cameron

Well-Known Member
Licensed User
Longtime User
B4X:
Label3.Top = Label2.Bottom + ((Label4.Top - Label2.Bottom) - Label3.Height) / 2

It makes a difference as the activity code lacks the ".Bottom" attribute.
 
Upvote 0

techknight

Well-Known Member
Licensed User
Longtime User
That one worked. Wish my math skills were a bit better as I dont think I would have figured that one out.
 
Upvote 0
Top