iOS Question How can I use AttributeString to change the font size of a dynamic label?

davepamn

Active Member
Licensed User
B4X:
        Dim tcContract As TableCell=tvContracts.AddSingleLine("")
        tcContract.ShowSelection=False
        tcContract.Tag=""
        tcContract.CustomView=Createitem(sContractNumber)

  
Private Sub Createitem(sValue As String) As Panel
    Dim oPanel As Panel
    Dim lblData As Label
    oPanel.Initialize("")
    lblData.Initialize("data")

    Dim oValueText As AttributedString
    oValueText.Initialize(sValue,Font.CreateNew(30),Colors.Blue)

    lblData.Text=sValue
    lblData.Color=Colors.ARGB(255,176,224,230)

    oPanel.Width=100%x
    oPanel.Height=tvContracts.RowHeight
    oPanel.AddView(lblData,0,0,100%x,tvContracts.RowHeight)

    Return(oPanel)

End Sub
I can't see a way to change the label size without using designer. If I used designer, how would I layout the label so it does not take up the full screen on the tableview cell.
 
Last edited:

davepamn

Active Member
Licensed User
B4X:
Private Sub Createitem(tvTableview As TableView, sValue As String,iAlpha As Int, iRed As Int, iGreen As Int, iBlue As Int,iFontSize As Int,iFontColor As Int) As Panel

    Dim oPanel As Panel

    Dim lblData As Label

    oPanel.Initialize("")

    lblData.Initialize("data")

    lblData.Text=sValue

    lblData.color=Colors.ARGB(iAlpha,iRed,iGreen,iBlue)

    lblData.Font=Font.CreateNew(iFontSize)

    lblData.TextColor=iFontColor

    oPanel.Width=100%x

    oPanel.Height=tvTableView.RowHeight
 
    oPanel.AddView(lblData,0,0,100%x,tvTableview.RowHeight)

    Return(oPanel)

End Sub
Final code
 

Brian Robinson

Active Member
Licensed User
B4X:
Private Sub Createitem(tvTableview As TableView, sValue As String,iAlpha As Int, iRed As Int, iGreen As Int, iBlue As Int,iFontSize As Int,iFontColor As Int) As Panel
Hi, If you are not using the separate color values iRed, iGreen etc, you could just pass the color through as an Int

B4X:
Private Sub Createitem(tvTableview As TableView, sValue As String,iBackColor as Int,iFontSize As Int,iFontColor As Int) As Panel
Then set
B4X:
lblData.color=Colors.ARGB(iBackColor)
Just a thought.

Cheers
Brian
 
Top