Search code examples
basic4android

Centering a panel on screen


I've been playing with centering a panel on a device screen. I've tried a few things but cant get the syntax/math correct. I am adding the panel with it's size relative to the screen size as below (80% width and 40% height). At the moment I left the x,y location at 0,0 - Any suggestions on correct syntax to center on screen are appreciated!

Activity.AddView(quitsavepnl,0,0, 80%x, 40%y)

Solution

  • Here:

    Activity.AddView(quitsavepnl, 50%x - 80%x / 2, 50%y - 40%y / 2, 80%x, 40%y)