B4J Question [ABMaterial] (Solved) Centering text in a label

JakeBullet70

Well-Known Member
Licensed User
Longtime User
Stupid question number 4309... o_O

Trying to center a label and text on a footer. I am using the code from the demo project.
What I am doing:
Sub BuildFooterFixed(page As ABMPage)
    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 = 200
   
    page.Footer.AddRows(1, True, "").AddCellsOS( 1 ,0,0,0, 6,6,6, "")
    page.Footer.BuildGrid 'IMPORTANT once you loaded the complete grid AND before you start adding components
    page.Footer.UseTheme("footertheme")
End Sub

Sub ConnectFooterFixed(page As ABMPage)
   
    Dim ScreenWidth As Int = gbl.GetScreenWidth(page)
    If ScreenWidth < 601 Then
        page.IsFixedFooter = False
        page.PaddingBottom = 0
    End If

    Dim lbl2 As ABMLabel
    lbl2.Initialize(page, "footlbl2", "TaskPro Copyright @1995-1999 / Simple Service Schedular @Copyright 2021", ABM.SIZE_SMALL,  False, "normal")
    page.Footer.Cell(1,1).AddComponent(lbl2)


What I want is a single line and the text to be centered. What I am getting is this: (Extra line break and not centered)
1631168352120.png
 
Last edited:
Solution
You will probably have to make a new Cell theme to center its contents:

something like:
B4X:
' In BuildPage or BuildTheme
theme.AddCellTheme("centre")
theme.Cell("centre").Align=ABM.CELL_ALIGN_CENTER

' when you build the grid:
page.footer.AddRowsM(1,True,0,0, "").AddCells12(1,"centre") '<--- using the centre theme

Alwaysbusy

JakeBullet70

Well-Known Member
Licensed User
Longtime User
Changed
B4X:
page.Footer.AddRows(1, True, "").AddCellsOS( 1 ,0,0,0, 6,6,6, "")
To
B4X:
page.footer.AddRowsM(1,True,0,0, "").AddCells12(1,"")

That fixed the line break. Still not centered though. I am learning!
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
You will probably have to make a new Cell theme to center its contents:

something like:
B4X:
' In BuildPage or BuildTheme
theme.AddCellTheme("centre")
theme.Cell("centre").Align=ABM.CELL_ALIGN_CENTER

' when you build the grid:
page.footer.AddRowsM(1,True,0,0, "").AddCells12(1,"centre") '<--- using the centre theme

Alwaysbusy
 
Upvote 2
Solution
Top