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: 627
  • MaterialIconsV2.0.zip
    224 KB · Views: 686
Last edited:

corwin42

Expert
Licensed User
Longtime User
I just tried this library.

The MaterialDrawableBuilder is useless in the current implementation. The main method to set the Icon is missing. Would be even nice if the setAlpha() method will get wrapped.

Btw. the library was updated with many more new icons...
 

DonManfred

Expert
Licensed User
Longtime User
The main method to set the Icon is missing.
What do you mean exactly? It IS there. And it was there in the "old" implementation. But you cant set the icon with it´s name... You only can set the index of the icon you want to use. See example-code. That´s the way the github project exüect the icon to set.

If you know a easy way to change the enum used by the github project so be a setter with the name of the icon; show me how and i´ll do if not much work.

I´ve updated the lib to use the newest github release. Now 1712 Icons.

The #additionalres is no longer needed. Also not the fontfile in the assets (it is now inside the aar).
 

corwin42

Expert
Licensed User
Longtime User
What do you mean exactly? It IS there. And it was there in the "old" implementation. But you cant set the icon with it´s name... You only can set the index of the icon you want to use. See example-code. That´s the way the github project exüect the icon to set.

I'm talking about the MaterialDrawableBuilder, not the MaterialIconView. The MaterialDrawableBuilder doesn't have the Icon property. You cannot set an Icon so the object is useless. I tried to use it but get the error that no icon was choosen.
 

jayel

Active Member
Licensed User
Longtime User
I get this error when compiling :
B4A version: 6.00
Parsing code. (0.00s)
Compiling code. (0.32s)
Compiling layouts code. (0.01s)
Organizing libraries. (0.00s)
Generating R file. Error
..\resources\values\attrs.xml:3: error: Attribute "materialIconSize" has already been defined
..\resources\values\attrs.xml:5: error: Attribute "materialIconColor" has already been defined
..\resources\values\attrs.xml:7: error: Attribute "materialIcon" has already been defin
 

jayel

Active Member
Licensed User
Longtime User
hello,

How can I set the logodrawable with an icon from materialicons?

B4X:
    Dim mi As MaterialIconView
    mi.Initialize("MaterialIcon")
    mi.Icon = 153
    mi.Color = 0xFF045B32
    ActionBar1.LogoDrawable = mi  <---- ERROR
 

Scantech

Well-Known Member
Licensed User
Longtime User
My large project will not work with Materialcon 2.0 using B4A 8.80 and 9.00. Material Icon 1.5 works ok with B4A 8.80 but B4A 9.00 will not work. MaterialIcon 1.5 and 2.0 will not work with B4A 9.00

*** Service (starter) Create ***
Using FileProvider? true
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Class not found: de.donmanfred.MaterialIconViewWrapper, trying: scantech.cardiagnosticpro.MaterialIconViewWrapper
Error occurred on line: 4858 (Main)
java.lang.RuntimeException: java.lang.ClassNotFoundException: scantech.cardiagnosticpro.MaterialIconViewWrapper
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:170)
at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:180)
at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:262)
at scantech.cardiagnosticpro.main._initmenu(main.java:1416)
at scantech.cardiagnosticpro.main._activity_create(main.java:1264)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at scantech.cardiagnosticpro.main.afterFirstLayout(main.java:104)
at scantech.cardiagnosticpro.main.access$000(main.java:17)
at scantech.cardiagnosticpro.main$WaitForLayout.run(main.java:82)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
Caused by: java.lang.ClassNotFoundException: scantech.cardiagnosticpro.MaterialIconViewWrapper
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:400)
at java.lang.Class.forName(Class.java:326)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:390)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:454)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:454)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:148)
... 27 more
Caused by: java.lang.ClassNotFoundException: Didn't find class "scantech.cardiagnosticpro.MaterialIconViewWrapper" on path: DexPathList[[zip file "/data/app/scantech.cardiagnosticpro-2/base.apk"],nativeLibraryDirectories=[/data/app/scantech.cardiagnosticpro-2/lib/x86, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 34 more
MAP READ
Panel size is unknown. Layout may not be loaded correctly.
MAP READ
** Activity (main) Resume **
 
Top