Android Question Dynamic change label text properties

EvgenyB4A

Active Member
Licensed User
Longtime User
Is it possible to change dynamically the text colour and size within the label?
Assume I want to display the currency symbol and total sum within the single label, where currency symbol text size and colour are different from the total sum ones
 

Mahares

Expert
Licensed User
Longtime User
Using the RichString library you can achieve that. Here is a link to the lib:
https://www.b4x.com/android/forum/threads/richstring-library.10680/#content

Here is a code example to give you an idea:
B4X:
Dim rs As RichString   'Need the richString lib
rs.Initialize("{SIZE}{Red}${Red}{SIZE}{SIZE2}{Cyan}2075{Cyan}{SIZE2}")
        rs.Color2(Colors.Red, "{Red}")
        rs.Color2(Colors.Cyan,"{Cyan}")      
        rs.RelativeSize2(1.5,"{SIZE}") 
        rs.RelativeSize2(.85,"{SIZE2}")
        Label2.Text =rs  'will display $2075 as:  $ in red and big font, 2075 in cyan and smaller
But you question should have been asked in the 'Question' forum instead of this forum.
 
Upvote 0

EvgenyB4A

Active Member
Licensed User
Longtime User
Using the RichString library you can achieve that. Here is a link to the lib:
https://www.b4x.com/android/forum/threads/richstring-library.10680/#content

Here is a code example to give you an idea:
B4X:
Dim rs As RichString   'Need the richString lib
rs.Initialize("{SIZE}{Red}${Red}{SIZE}{SIZE2}{Cyan}2075{Cyan}{SIZE2}")
        rs.Color2(Colors.Red, "{Red}")
        rs.Color2(Colors.Cyan,"{Cyan}")     
        rs.RelativeSize2(1.5,"{SIZE}")
        rs.RelativeSize2(.85,"{SIZE2}")
        Label2.Text =rs  'will display $2075 as:  $ in red and big font, 2075 in cyan and smaller
But you question should have been asked in the 'Question' forum instead of this forum.
Thank you very much for help.
 
Upvote 0
Top