iOS Question Problems with placement of programmatically added views

Jack Cole

Well-Known Member
Licensed User
Longtime User
***ADMIN - PLEASE DELETE THIS POST***

I'm having a lot of trouble with placement of programmatically added views. It may be some misunderstanding that I have in comparing to B4A. I have attached a simple example.

In the following example, I programmatically add a scrollview, and a grid of 6x6 of imageviews. The imageviews should have 15dip of space in between, but the result is one big square with no spacing between.

I haven't attached an example for other problems, but there seems to be something unusual and inconsistent about adding a layout and then trying to add additional views programmatically.

Here is the code for adding the scrollview and grid.

B4X:
Sub AddViews
    sv.Initialize("sv",1000,1000)
    Page1.RootPanel.AddView(sv,0,90dip,100%x-90dip,100%y-90dip)
    For x=0 To 5
        For y=0 To 5
            Dim img As ImageView
            img.Initialize("")
            img.Color=Colors.Black
            sv.Panel.AddView(img,x*50dip+15dip,y*50dip+15dip,50dip,50dip)
        Next
    Next
End Sub
 

Attachments

  • viewstesting.zip
    1 KB · Views: 160
Last edited:
Top