I am trying to substitute MSIconicDrawable with the B4A inbuilt support for FontAwsome.
To display FontAwsome Bitmap on DSNavigation drawer, I am trying to use the Sub named TextToBitmap() shared by Erel.
How do I change the color of the Icon/Bitmap created using the Sub TextToBitmap ?. I am trying to place the Icon/Bitmap created using the Sub TextToBitmap() on the DSNavigationDrawer. DSNavigationDrawer expects either a Bitmap or BitmapDrawable to display the Icon on the Drawer.
In the following code, I tried replacing different colors, unfortunately, there seems no difference. Whatever color I use the Bitmap appears in Black color only cvs.DrawText(s, bmp.Width / 2, bmp.Height / 2 + h / 2, Typeface.FONTAWESOME, FontSize, Colors.White, "CENTER")
The code doesn't have any effect on the color of the Bitmap/icon.
Any help will be appreciated.
To display FontAwsome Bitmap on DSNavigation drawer, I am trying to use the Sub named TextToBitmap() shared by Erel.
How do I change the color of the Icon/Bitmap created using the Sub TextToBitmap ?. I am trying to place the Icon/Bitmap created using the Sub TextToBitmap() on the DSNavigationDrawer. DSNavigationDrawer expects either a Bitmap or BitmapDrawable to display the Icon on the Drawer.
In the following code, I tried replacing different colors, unfortunately, there seems no difference. Whatever color I use the Bitmap appears in Black color only cvs.DrawText(s, bmp.Width / 2, bmp.Height / 2 + h / 2, Typeface.FONTAWESOME, FontSize, Colors.White, "CENTER")
The code doesn't have any effect on the color of the Bitmap/icon.
B4X:
'When using MSIconicDrawable, here I have the option to change the color of the icon
Dim IconHome As MSIconicDrawable : IconHome.Initialize("gmd_home") : IconHome.Color = 0xffff4081
'In this case how do I change the color of the icon ? ie TextToBitmap(Chr(0xF0EE), 30)
Dim oBitMap As BitmapDrawable
oBitMap.Initialize(TextToBitmap(Chr(0xF0EE), 30))
NavDrawer.NavigationView.Menu.AddWithGroup2(1, 1, 1, "Home", oBitMap ).Checked = True
NavDrawer.NavigationView.Menu.AddWithGroup(1, 2, 2, "My Menu", TextToBitmap(Chr(0xF209), 30) ).Checked = True
Sub TextToBitmap (s As String, FontSize As Float) As Bitmap
Dim bmp As Bitmap
bmp.InitializeMutable(32dip, 32dip)
Dim cvs As Canvas
cvs.Initialize2(bmp)
Dim h As Double = cvs.MeasureStringHeight(s, Typeface.FONTAWESOME, FontSize)
'Tried changing the color in the next line, but no effect on the final image. It is appearing as grey only
cvs.DrawText(s, bmp.Width / 2, bmp.Height / 2 + h / 2, Typeface.FONTAWESOME, FontSize, Colors.White, "CENTER")
Return bmp
End Sub
Any help will be appreciated.