Android Question Relative position from variable

gruizelgruis

Member
Licensed User
Longtime User
Hi all,

I try to position a button using variabels:

B4X:
pnl.AddView(p, Cur_TafelGeg.TLeft,  Cur_TafelGeg.Ttop, Cur_TafelGeg.TWidth , Cur_TafelGeg.THeight)

The value's held by tleft, ttop ...etc are ment to be relative positions.
How do I represent the value "50" held in ttop as a 50%y value

PLease advice
 

Troberg

Well-Known Member
Licensed User
Longtime User
Simply put the value 50%y into Ttop. The real pixel value will be put into Ttop.

So, on a device with, say, 1024 height, this:

B4X:
Cur_TafelGeg.Ttop = 50%y
Log(Cur_TafelGeg.Ttop)

will result in this:

512

(or, possibly 511, as it's zero-based).
 
Upvote 0

gruizelgruis

Member
Licensed User
Longtime User
The 4 position Values come from outside vba, its send to the app by a VB6 program.
All I have is the value 50, that needs to get converted to 50%x

I found this works:
B4X:
Test = Cur_TafelGeg.TLeft * 1%x
 
Upvote 0
Top