Other [new feature] FontAwesome and Material Icons

Status
Not open for further replies.

Erel

B4X founder
Staff member
Licensed User
Longtime User
1500 new icons to be included in the next update of B4A, as two easy to work with fonts.

SS-2016-11-30_17.17.30.png


upload_2016-11-30_17-20-14.png


You can see more information here: https://www.b4x.com/android/forum/threads/fontawesome-material-icons-fonts.72908/#content
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
When will be ready the next Rel B4A ?
The beta version is almost ready.

But will be possible set FontAwesome + Text, right ?
Yes. The icons are regular characters. The picker just copies them to the clipboard.
See the tips section at the end of the tutorial.
 
Upvote 0

corwin42

Expert
Licensed User
Longtime User
Will it be possible to create Drawables on the fly from the IconFonts so we can use them for ActionItems in the Menu or in the NavigationView (DesignSupport lib) ?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
SS-2016-12-01_09.30.23.png


The icons are regular characters. It is possible to convert them to drawables with:
B4X:
Sub Activity_Create(FirstTime As Boolean)
   Activity.AddMenuItem3("Apple", "Test", TextToBitmap(Chr(0xF179), 28), True)
   Activity.AddMenuItem3("Android", "Test", TextToBitmap(Chr(0xF17B), 28), True)
End Sub

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, lblfontAwesome.Typeface, FontSize)
   cvs.DrawText(s, bmp.Width / 2, bmp.Height / 2 + h / 2, lblfontAwesome.Typeface, FontSize, Colors.White, "CENTER")
   Return bmp
End Sub

Note that the Chr(0xxxx) comes from the code editor icon picker.
 
Upvote 0

MarcoRome

Expert
Licensed User
Longtime User
Note that the Chr(0xxxx) comes from the code editor icon picker.

Sorry Erel maybe i dont understand. But where can i see this Code Chr(0xxx), because if i select i copy "pictures", but dont see code.
Where i wrong ?
Thank you
 
Upvote 0

Sapta

Member
Licensed User
Longtime User
SS-2016-12-01_09.30.23.png


The icons are regular characters. It is possible to convert them to drawables with:
B4X:
Sub Activity_Create(FirstTime As Boolean)
   Activity.AddMenuItem3("Apple", "Test", TextToBitmap(Chr(0xF179), 28), True)
   Activity.AddMenuItem3("Android", "Test", TextToBitmap(Chr(0xF17B), 28), True)
End Sub

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, lblfontAwesome.Typeface, FontSize)
   cvs.DrawText(s, bmp.Width / 2, bmp.Height / 2 + h / 2, lblfontAwesome.Typeface, FontSize, Colors.White, "CENTER")
   Return bmp
End Sub

Note that the Chr(0xxxx) comes from the code editor icon picker.


Hi @Erel
According this code, I use in Icon but error
B4X:
NavDrawer.NavigationView.Menu.AddWithGroup2(2, 3, 1000, "Setting", XML.GetDrawable("ic_settings_black_24dp"))

to ..
B4X:
NavDrawer.NavigationView.Menu.AddWithGroup2(2, 3, 1000, "Setting", TextToBitmap(Chr(0xF179), 28))

got error : java.lang.IllegalArgumentException: method de.amberhome.objects.appcompat.ACMenuWrapper.AddWithGroup2 argument 5 has type android.graphics.drawable.Drawable, got android.graphics.Bitmap

What this mean?
Thank you
 
Upvote 0

Emme Developer

Well-Known Member
Licensed User
Longtime User
Hi @Erel
According this code, I use in Icon but error
B4X:
NavDrawer.NavigationView.Menu.AddWithGroup2(2, 3, 1000, "Setting", XML.GetDrawable("ic_settings_black_24dp"))

to ..
B4X:
NavDrawer.NavigationView.Menu.AddWithGroup2(2, 3, 1000, "Setting", TextToBitmap(Chr(0xF179), 28))

got error : java.lang.IllegalArgumentException: method de.amberhome.objects.appcompat.ACMenuWrapper.AddWithGroup2 argument 5 has type android.graphics.drawable.Drawable, got android.graphics.Bitmap

What this mean?
Thank you
TextToBitmap return a bitmap, AddWithGroup2 Expect a Drawable

B4X:
Dim bd As BitmapDrawable
    bd.Initialize(TextToBitmap(Chr(0xF179), 28))
    NavDrawer.NavigationView.Menu.AddWithGroup2(2, 3, 1000, "Setting", bd)
 
Upvote 0
Status
Not open for further replies.
Top