Description:
Erel’s recent code snippet regarding Material Icons and Richtsring inspired me to write the following snippet combining a FontAwesome Icon, text and Richstring to put text on a label, button, edittext, etc. The following code which can be enhanced, is the entire project:
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
Tags: Richstring, Fontawesome
Dependency: Richstring Library (that’s all)
			
			Erel’s recent code snippet regarding Material Icons and Richtsring inspired me to write the following snippet combining a FontAwesome Icon, text and Richstring to put text on a label, button, edittext, etc. The following code which can be enhanced, is the entire project:
			
				B4X:
			
		
		
		Sub Globals
    Private Label1 As Label
    Private lblFontAwesomeIcon As Label
End Sub
Sub Activity_Create(FirstTime As Boolean)
    Activity.loadlayout("1")  'layout has 2 labels: Label1 and lblFontAwesomeIcon
    Label1.Typeface = lblFontAwesomeIcon.Typeface   'lblFontAwesomeIcon must have fontawesome Typeface. Can be invisible.
    Label1.text = FontAwesomeIconsWithRichString("0xF0B2", "B4A Takes You Anywhere!", 2.75)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
    If UserClosed Then Activity.Finish
End Sub
Sub FontAwesomeIconsWithRichString(HexCode As String, Text As String, IconRelativeSize As Float) As RichString
    Dim rs As RichString
    HexCode=HexCode.Replace("0x","")
    Dim intHC As Int = Bit.ParseInt(HexCode, 16)
    rs.Initialize($"{SIZE2}{C}${Chr(intHC)}  {C}{SIZE2}{B}${Text}{B}"$)
    rs.RelativeSize2(IconRelativeSize,"{SIZE2}")
    rs.Color2(Colors.Cyan,"{C}")
    rs.Style2(rs.STYLE_BOLD_ITALIC,"{B}")
    Return rs
End SubDependency: Richstring Library (that’s all)
 
				 
			 
 
		 
			 
 
		 
 
		 
 
		