Android Question Relative position from variable

Discussion in 'Android Questions' started by gruizelgruis, Mar 25, 2015.

  1. gruizelgruis

    gruizelgruis Member Licensed User

    Hi all,

    I try to position a button using variabels:

    Code:
    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
     
  2. Troberg

    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:

    Code:
    Cur_TafelGeg.Ttop = 50%y
    Log(Cur_TafelGeg.Ttop)
    will result in this:

    512

    (or, possibly 511, as it's zero-based).
     
  3. gruizelgruis

    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:
    Code:
    Test = Cur_TafelGeg.TLeft * 1%x
     
  4. Troberg

    Troberg Well-Known Member Licensed User

    Ah, well, then I think your method is the easiest.
     
    gruizelgruis likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice