B4J Question Change font size in second line of a button

Peter Lewis

Active Member
Licensed User
Longtime User
Apart from using BBcodeview, is there anyway of changing the font size on a second line of a button. the text of the second line is a mixture of text and the result from a Database

Thank you
 
Solution
In B4J there is the Textflow class: https://www.b4x.com/android/forum/threads/class-textflow-similar-to-b4a-b4i-richstring.61237/
(Class is in attached .zip example)

However, to make it into a button, you have to put it into a Pane that is responsive to MouseClicked event.
You also have to make the pane look like a button. Easier to do with the B4XView cast.

See example below (I put it into a B4X pages template, because I always do) but it will also work in the default template (with xui and jFx).

B4X:
Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    Private fx As JFX
End Sub

Public Sub Initialize
End Sub

'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created...

William Lancee

Well-Known Member
Licensed User
Longtime User
In B4J there is the Textflow class: https://www.b4x.com/android/forum/threads/class-textflow-similar-to-b4a-b4i-richstring.61237/
(Class is in attached .zip example)

However, to make it into a button, you have to put it into a Pane that is responsive to MouseClicked event.
You also have to make the pane look like a button. Easier to do with the B4XView cast.

See example below (I put it into a B4X pages template, because I always do) but it will also work in the default template (with xui and jFx).

B4X:
Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    Private fx As JFX
End Sub

Public Sub Initialize
End Sub

'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Dim TF As TextFlow
    TF.Initialize
    TF.AddText("1 2 3").SetColor(fx.Colors.Red).SetUnderline(True)
    TF.AddText(CRLF & " 4 5 6 ").SetColor(fx.Colors.Green).SetFont(fx.CreateFont("", 17, True, True))
    TF.AddText(CRLF & "7 8 9").SetColor(fx.Colors.Blue).SetStrikethrough(True).SetFont(fx.DefaultFont(20))
    Dim pane As Pane = TF.CreateTextFlow                    'This pane does not have an click event
    Dim responsePaneX As B4XView = xui.CreatePanel("TF")    'This pane DOES have an mouseClicked event
    responsePaneX.AddView(pane, 10, 10, 70, 100)
    responsePaneX.Tag = "1 2 3 4 5 6 7 8 9"
    Root.AddView(responsePaneX, 10, 10, 70, 100)
    responsePaneX.SetColorAndBorder(xui.Color_RGB(220, 220, 220), 1, xui.Color_RGB(180, 180, 180), 10)
End Sub

Private Sub TF_MouseClicked(ev As MouseEvent)
    Dim vx As B4XView = Sender
    Log(vx.tag)            '1 2 3 4 5 6 7 8 9
End Sub

textflowBtn.png
 

Attachments

  • TFBtn.zip
    9.1 KB · Views: 10
Upvote 2
Solution
Top