Hi all,
May I know how to set the horizontalCenter/verticalCenter of view in main program?
I can find the Horizontal/Vertical Center properties in the visual designer but how can I set the value in the main program?
Dim v As View
...
' find the center coordinates:
Dim cx,cy As Int
cx = v.Left + v.Width/2
cy = v.Top + v.Height
' or
' put the view there:
v.Left = cx - v.Width/2
v.Top = cy - v.Height/2
Dim v As View
...
' find the center coordinates:
Dim cx,cy As Int
cx = v.Left + v.Width/2
cy = v.Top + v.Height
' or
' put the view there:
v.Left = cx - v.Width/2
v.Top = cy - v.Height/2
Oh i see, thank you.
Thats mean dont have a direct way to do it?
B4X:
Sub SetHorizontalCenter(v As View,HorizontalCenter As Float)
v.Left = HorizontalCenter - (v.Width/2)
End Sub
Sub SetVerticalCenter(v As View,VerticalCenter As Float)
v.Top = VerticalCenter + (v.Height/2)
End Sub
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.