Setting label text to bold

Status
Not open for further replies.

rleiman

Well-Known Member
Licensed User
Longtime User
Hi Everyone,

Can you show the needed coding that will apply Bold to the Text of a label?

I tried this but the syntax is wrong:

B4X:
LabelStoreName.Typeface = Typeface.STYLE_BOLD

Thanks.
 

mangojack

Well-Known Member
Licensed User
Longtime User
Try this ..

B4X:
LabelStoreName.Typeface = Typeface.DEFAULT_BOLD

Cheers mj
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
You can also set it in the designer:
SS-2013-02-22_11.19.28.png
 
Upvote 0

rleiman

Well-Known Member
Licensed User
Longtime User
Hi Everyone,

Thanks for the replies.

The coding from mangojack worked. :D

Maybe .STYLE_BOLD should be removed from the Intelisence results because that's how I found it.

Erel,

Thanks for the helpful reply as well.
 
Upvote 0

Eksatech

Member
Licensed User
Longtime User
Hi All,
I tried all of above suggestions but I can't made bold the label text. None of these codes working.

Where is my mistake? Can anyone helps me please.

B4X:
    Dim MyFont As Typeface
    MyFont = Typeface.LoadFromAssets("arial_condensed_bold.ttf")

    Dim lblCustomer As Label
    lblCustomer.Initialize("")
    lblCustomer.Typeface=MyFont    
    lblCustomer.Typeface=Typeface.DEFAULT_BOLD
    lblCustomer.Gravity = Bit.OR(Gravity.CENTER_VERTICAL, Gravity.LEFT)
    lblCustomer.Text = CusName
    lblCustomer.TextSize=20
    lblCustomer.TextColor=Colors.RGB(6,14,172)

B4X:
    Dim lblCustomer As Label
    lblCustomer.Initialize("")
    lblCustomer.Typeface=Typeface.CreateNew(Typeface.LoadFromAssets("arial_condensed_bold.ttf"),Typeface.STYLE_BOLD)
    lblCustomer.Gravity = Bit.OR(Gravity.CENTER_VERTICAL, Gravity.LEFT)
    lblCustomer.Text = CusName
    lblCustomer.TextSize=20
    lblCustomer.TextColor=Colors.RGB(6,14,172)
 
Upvote 0

RandomCoder

Well-Known Member
Licensed User
Longtime User
What you've done looks correct to me. Maybe try moving the line where you set bold to the last line i.e. after setting it's text, size and color. Worth a shot?
 
Upvote 0

Eksatech

Member
Licensed User
Longtime User
Thanks for your suggestion RandomCoder but problem isn't solved. I changed line to end but still didn't make bold.
 
Upvote 0

RandomCoder

Well-Known Member
Licensed User
Longtime User
Does your code work if you use a standard font?
Of not then I think we may need to see more code.
 
Upvote 0

Tamer El-Shimy

Member
Licensed User
Longtime User
Hi Everyone,

Can you show the needed coding that will apply Bold to the Text of a label?

I tried this but the syntax is wrong:

B4X:
LabelStoreName.Typeface = Typeface.STYLE_BOLD

Thanks.
This doesn't work because Style Bold returns integer unlike Typeface "Data Type".
 
Upvote 0
Status
Not open for further replies.
Top