iOS Question Positioning a panel in the centre of the screen

Sanxion

Active Member
Licensed User
Longtime User
Hi all

I am using the following to centre my panels (I have lots of them):

B4X:
Sub PositionThePanels

    For Each v As View In Page1.RootPanel
        If v Is Panel Then 

            Dim PanelTag As String
            PanelTag = v.Tag

            If PanelTag.StartsWith("Lesson") Then
                  v.Left = (Page1.RootPanel.Width - v.Width) / 2
                  v.Top = (Page1.RootPanel.Height - v.Height) / 2
            End If
        End If

    Next
  
End Sub

The code does centre the panels...however, once the Sub has finished executing, the panels move back to the position they are in the designer.

Does anybody know why?

Thanks
 

Yvon Steinthal

Active Member
Licensed User
Longtime User
I have no idea why it happens, but i would create the panel programmatically if the designer is a problem...
 
Upvote 0

tufanv

Expert
Licensed User
Longtime User

I sometimes use outside the resize but use a value within the resize event. Is it ok ?
What i mean is for example under resize i use:
widthreal = 100%x
heightreal=100%y

than use widthreal*0.5 for 50%x for example
 
Upvote 0

Sanxion

Active Member
Licensed User
Longtime User
Yes I did that earlier and it worked.

Does that mean whenever I am setting the size of views, the code that does it should be called from Page_Resize?
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…