B4J Question [ABMaterial] cell(x,y).addcomponent incorrectly position

jinyistudio

Well-Known Member
Licensed User
Longtime User
Hi

following is a footer. It has a grid as following
B4X:
Sub BuildFooterFixed(page As ABMPage,PaddingBotton As Int,theme As String)
    page.isFixedFooter= True
    ' because we have a fixed footer at the bottom, we have to adjust the padding of the body in pixels
    page.PaddingBottom = PaddingBotton   
    page.Footer.AddRowsM(1, True,4,4, "").AddCellsOSMP(6,0,0,0,2,2,2,0,0,0,0, "")
    page.Footer.BuildGrid 'IMPORTANT once you loaded the complete grid AND before you start adding components
    '
    page.Footer.UseTheme(theme)
End Sub

I put two button into the cell(1,5) cell(1,6) of grid of footer. Why does its showing position incorrectly !?
B4X:
Shared.BuildFooterFixed(page,200,"")
    Dim btn2 As ABMButton
    btn2.InitializeRaised(page, "svgsave", "mdi-navigation-cancel", "", "存檔", "darkgreen")
    page.Footer.Cell(1,6).AddComponent(btn2)
    Dim btn3 As ABMButton
    btn3.InitializeRaised(page, "svgdelete", "mdi-content-add-circle", "", "刪除", "darkgreen")
    page.Footer.Cell(1,5).AddComponent(btn3)


ac6b0f74091c18fb960c26c8926d920c.png
 

mindful

Active Member
Licensed User
Because all previous cells are empty. You need to use addcellsosmp method and specify and offset for cell 6.
 
Upvote 0

stanmiller

Active Member
Licensed User
Longtime User
I believe this should do what you want:
B4X:
page.Footer.AddRowsM(1, True,4,4, "").AddCellsOSMP(2,8,8,8,2,2,2,0,0,0,0, "")

The above definition will add one row with two content cells. The row begins with an offset spanning 8 grid cells followed by the content cells which span 2 grid cells each.

8 + 1x2 + 1x2 = 12 grid cells.


The offset consumes 8 grid cells of the row, that means the content cells are now at (1,1) and (1,2).
B4X:
Shared.BuildFooterFixed(page,200,"")
    Dim btn2 As ABMButton
    btn2.InitializeRaised(page, "svgsave", "mdi-navigation-cancel", "", "存檔", "darkgreen")
    page.Footer.Cell(1,2).AddComponent(btn2)
    Dim btn3 As ABMButton
    btn3.InitializeRaised(page, "svgdelete", "mdi-content-add-circle", "", "刪除", "darkgreen")
    page.Footer.Cell(1,1).AddComponent(btn3)
 
Last edited:
Upvote 0

jinyistudio

Well-Known Member
Licensed User
Longtime User
page.Footer.AddRowsM(1, True,4,4, "").AddCellsOSMP(2,8,8,8,2,2,2,0,0,0,0, "") :eek:

944abacb8480ed72d0569498f1e3d1cb.png
 
Upvote 0

stanmiller

Active Member
Licensed User
Longtime User
This means that the two grid cells are not wide enough for the content as cell (1,2) is wrapping. You could reduce the offset and widen the content cells but that probably won't give the expected results.

A better solution is to nest the buttons in a container, then place them in a row and use an offset/cells to position the container. That gives you more control of the location on the page.

Here's an example of a row with two content-cells and containers holding the content. Note that the left container is left justified while the right container (Github, GooglePlus, and LinkedIn buttons) is aligned right.

https://macthomasengineering.com:8443/mte/home/index.html?v=116

2_footer_layout_zpsyjidvubu.jpg


To sort this out, start with the ABM Gridbuilder. This is difficult to do by hand.
 
Last edited:
Upvote 0
Top