B4X:
Sub Activity_CreateMenu(Menu As ACMenu)
Menu.Clear
Menu.Add(0, 0, Chr(0xE8B8) & " " & "Setting", Null)
Menu.Add(1, 0, Chr(0xE8B8) & " " &"Export/Import", Null)
Menu.Add(2, 0, Chr(0xE88F) & " " &"About", Null)
Menu.Add(3, 0, Chr(0xE879) & " " & "Exit", Null)
End Sub
or
B4X:
Sub Activity_CreateMenu(Menu As ACMenu)
Menu.Clear
Menu.Add(0, 0,"Setting", FontToBitmap(Chr(0xE8B8),True,14,Colors.White))
Menu.Add(1, 0, "Export/Import", FontToBitmap(Chr(0xE8B8),True,14,Colors.White))
Menu.Add(2, 0,"About", FontToBitmap(Chr(0xE88F),True,14,Colors.White))
End Sub
Public Sub FontToBitmap (text As String, IsMaterialIcons As Boolean, FontSize As Float, color As Int) As B4XBitmap
Dim xui As XUI
Dim p As Panel = xui.CreatePanel("")
p.SetLayoutAnimated(0, 0, 0, 32dip, 32dip)
Dim cvs1 As B4XCanvas
cvs1.Initialize(p)
Dim t As Typeface
If IsMaterialIcons Then t = Typeface.MATERIALICONS Else t = Typeface.FONTAWESOME
Dim fnt As B4XFont = xui.CreateFont(t, FontSize)
Dim r As B4XRect = cvs1.MeasureText(text, fnt)
Dim BaseLine As Int = cvs1.TargetRect.CenterY - r.Height / 2 - r.Top
cvs1.DrawText(text, cvs1.TargetRect.CenterX, BaseLine, fnt, color, "CENTER")
Dim b As B4XBitmap = cvs1.CreateBitmap
cvs1.Release
Return b
End Sub
the menu didn't show up the the icon.
How to add icon to acmenu?