B4A Library 2046 MaterialIcons in the Color you need

This is a wrapper for this github project.

Requirement: B4A 6+

You can see a overview of Icons here: https://materialdesignicons.com/


MaterialIcons
Author:
DonManfred
Version: 2.0 (2046 Icons)
  • MaterialDrawableBuilder
    • Functions:
      • build As android.graphics.drawable.Drawable
      • clearColorFilter As MaterialDrawableBuilder
      • Initialize (EventName As String)
      • IsInitialized As Boolean
      • setAlpha (alpha As Int) As MaterialDrawableBuilder
      • setColorFilter (cf As android.graphics.ColorFilter) As MaterialDrawableBuilder
      • setColorResource (colorRes As Int) As MaterialDrawableBuilder
        Set the color of the drawable.
        colorRes: The color resource, from your R file.
        Return type: @return:The current IconDrawable for chaining.
      • setStyle (style As android.graphics.Paint.Style) As MaterialDrawableBuilder
        Sets paint style.
        style: to be applied
    • Properties:
      • Color As Int [write only]
      • Icon As String [write only]
      • Iconlist As List [read only]
      • Opacity As Int [read only]
      • SizeDp As Int [write only]
      • SizePx As Int [write only]
  • MaterialIconView
    • Fields:
      • ba As BA
    • Functions:
      • BringToFront
      • DesignerCreateView (base As Panel, lw As Label, props As Map)
      • Initialize (EventName As String)
      • Invalidate
      • Invalidate2 (arg0 As android.graphics.Rect)
      • Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
      • IsInitialized As Boolean
      • RemoveView
      • RequestFocus As Boolean
      • SendToBack
      • SetBackgroundImage (arg0 As android.graphics.Bitmap) As BitmapDrawable
      • SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)
      • SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
      • SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)
      • SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
    • Properties:
      • Background As android.graphics.drawable.Drawable
      • Color As Int [write only]
      • Enabled As Boolean
      • Height As Int
      • Icon As Int [write only]
      • Iconlist As List [read only]
      • Left As Int
      • Padding As Int()
      • Parent As Object [read only]
      • SizeDp As Int [write only]
      • SizePx As Int [write only]
      • Tag As Object
      • Top As Int
      • Visible As Boolean
      • Width As Int



B4X:
    mi.Initialize("MaterialIcon")
    mi.Color = Colors.Red
    Dim iconlist As List
    iconlist.Initialize
    iconlist = mi.Iconlist
    Log(iconlist)
    For i = 0 To 249
        mi2.Initialize("MaterialIcon")
        Dim idx As Int = Rnd(1,iconlist.Size)
        mi2.Icon = idx
        mi2.Color = Colors.RGB(Rnd(1,255),Rnd(1,255),Rnd(1,255))
        Dim posx As Int = Rnd(0,100%x-50dip)
        Dim posy As Int = Rnd(0,100%y-50dip)

        Activity.AddView(mi2,posx,posy,50dip,50dip)
    Next

MaterialIcons001.png
 

Attachments

  • MaterialIconsEx.zip
    6.9 KB · Views: 614
  • MaterialIconsV2.0.zip
    224 KB · Views: 673
Last edited:

BarryW

Active Member
Licensed User
Longtime User
How to put these icon into a bitmap so that i can use it on other view like ur library iconbutton... Tnx
 

joneden

Active Member
Licensed User
Longtime User
Does this generate the icon set on the fly or is it pre specified? Only there has just been a new set loaded and it would be nice to use something that is always upto date. I already use MSIconicDrawable but just dropping a new ttf file into the folder doesn't open up the new icons for use :( Hopefully yours will.
 

joneden

Active Member
Licensed User
Longtime User
it is a ttf font where the icons come from..

This is NOT based on the font used in msiconic drawable

Yes I'd seen the TTF bit but was really wondering if the code can handle just dropping the new TTF in.

Couple more questions

Is there a way to reference icons by name or is it purely index based (with corresponding edit of the attrs.xml file)

Is there a way to get the icon as a drawable? I want to use in the action bar and need it as a drawable to manage that.

Thanks in advance

Jon
 

DonManfred

Expert
Licensed User
Longtime User
Yes I'd seen the TTF bit but was really wondering if the code can handle just dropping the new TTF in.
no

Is there a way to reference icons by name or is it purely index based (with corresponding edit of the attrs.xml file)
No, the lib does not expose such a feature.
But you can get a list of all names which you could use to get the right index

B4X:
Dim iconlist As List
    iconlist.Initialize
    iconlist = mi.Iconlist

Is there a way to get the icon as a drawable?
no
 

joneden

Active Member
Licensed User
Longtime User
OK thanks for letting me know Manfred. Will you be developing this further with features such as the ones I was asking about?
 

Scantech

Well-Known Member
Licensed User
Longtime User
See updated lib (1.0.7) in post #1. 1341 Icons in the new ttf

Hey Manfred,

The Github attrs.xlm is incompatible with B4A. I believe it needs to be updated?? The Icons not matching with the names.

Any users downloading the example, you will need the attachment (old .ttf) until V1.07 gets resolved.
 

Attachments

  • MaterialIconsEx with 1.0 lib.zip
    96.1 KB · Views: 387

Scantech

Well-Known Member
Licensed User
Longtime User
Here is an updated attrs.xml.

This will show all icons with proper names.
 

Attachments

  • MaterialIconsEx use with v1.07 lib.zip
    109.1 KB · Views: 460

DonManfred

Expert
Licensed User
Longtime User
Will you be developing this further with features such as the ones I was asking about?
If the original lib will be updated i can do an update for the wrap. But i´m NOT able to save it as a Drawable or eben Bitmap.
And the list of names you can build by yourself (but i already said that).
 
Top