Android Question Relative position from variable

gruizelgruis

Member
Licensed 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
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).
 

gruizelgruis

Member
Licensed 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
 
Top