B4J Question Cannot set picture location

Shay

Well-Known Member
Licensed User
Longtime User
I am trying to load 8 x 4 picures
8 picture per row, picture by picture
4 rows
that will provide full big picture
I am running the following code, and getting gaps between the pictures, once I am manually fixing the width, and moving to height, the width is moving again
I dont know why it is not working (code was working ok on B4A)
I changed the code a bit to make it simplier to understand, of course dynamic screen solution is appriciated

B4X:
Sub ArrangeSquares()
    
    Dim calcX, calcY As Float
    Dim Width, Height As Float
    Dim Counter As Int = 1
    calcX = 0dip
    calcY = 0dip
    Width = ScreenWidth / 8
    Height = ScreenHeight / 4
    For i=1 To 4
        For x=1 To 8
            Dim iv As ImageView
            iv.Initialize("img" & i & x)
            img(Counter)= iv
            img(Counter).SetBitmap(xui.LoadBitmap(File.DirAssets, Main.Level &"_row-" & i & "-col-" & x & ".png"))
            Root.AddView(img(Counter), calcY, calcX, Width, Height)
            img(Counter).Tag = i & x
            'calcY = calcY + img(Counter).GetBitmap.Width
            calcY = calcY + Width
            If Counter = 32 Then
                Exit
            Else
                Counter = Counter + 1
            End If
        Next
        calcY = 0dip
        calcX = calcX + Height
    Next
 

Shay

Well-Known Member
Licensed User
Longtime User
Solved, thanks !!!
I actually tried it, but before the Root.addView and not after..
 
Upvote 0
Top