Android Question Set part of the label text to bold

Alex_197

Active Member
Licensed User
Hi all.

My question is - how to set part of the label text to bold?

Let say I have a label text such as

Client Name
Client address
Client Type

So I need to show only Client Name in bold and rest of the text is Normal.

Is it possible?

Thanks.

Be safe.
 

Mahares

Expert
Licensed User
So I need to show only Client Name in bold and rest of the text is Normal.
Here is another example along with the example that Jeffrey offered. They both give you a different flavor of what you can do with CSBuilder.
B4X:
Dim cs As CSBuilder
    cs.Initialize.Size(30).Typeface(Typeface.SANS_SERIF).Image(LoadBitmap(File.DirAssets, "brazil.png"), 60dip, 60dip, False)
    cs.Append("    Football").pop.Typeface(Typeface.DEFAULT_BOLD).Append(" IS KING")
    cs.PopAll
    Label1.Text = cs
 
Upvote 0

Erel

Administrator
Staff member
Licensed User
CSBuilder is a good option.

Another option is to use BCTextEngine:

i_view64_moYFWl4Ll7.png


B4X:
Sub Globals
    Private BBCodeView1 As BBCodeView
    Private TextEngine As BCTextEngine
    Private xui As XUI
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("1")
    TextEngine.Initialize(Activity)
    Activity.Color = xui.Color_White
    BBCodeView1.Text = $"[b]Client Name[/b]
Client address
Client Type
"$
End Sub
 
Upvote 0
Top