MSMaterialDrawer

BarryW

Active Member
Licensed User
Longtime User

Where is link for the library? Tnx...
 

bermooda

Member
Licensed User
Longtime User
just pass a parameter of type Object. like this:
Sub MD_Opened(p As Object)
...
End Sub
 

phukol

Active Member
Licensed User
Longtime User
Hi there guys, i seem to have issues in showing the msicondrawable? im trying to run the example in MSMaterialDrawer example but all i get is this. No icon is shown? what could be the issue? Also is it possible if i just use a typeface for the drawable instead of using msiconic?

I already copied them under Files/fonts folders. The filename were fontawesome-webfont-4.3.0.ttf and google_material_design.ttf
 

bermooda

Member
Licensed User
Longtime User
AFAIK you can not use just a typeface as drawable because it does not provide any drawable object by default and this is why you need to use MSIconic.
are you using SDK 23 or higher? and double check your additional resource pathes.
 

phukol

Active Member
Licensed User
Longtime User
AFAIK you can not use just a typeface as drawable because it does not provide any drawable object by default and this is why you need to use MSIconic.
are you using SDK 23 or higher? and double check your additional resource pathes.

Thank you. Yes i am using sdk 23 and the example included in MSMAterialDrawer is working. However when i try to follow my own example. its not working anymore. The icons are not showing.

Jut want to say that the icons will only show if i use Release or Release(Obfuscated). So far thats the only thing i did that worked. Can anyone confirm it also. Im using b4a 5.5
 
Last edited:

bermooda

Member
Licensed User
Longtime User
i had this kind of problem with iconic fonts. creating a copy of original example fonts folder and pasting it inside your project's Files folder may solve the problem.
Yes, i'm using B4A 5.5 too and also when i was using Release, fonts were fine.
 

joneden

Active Member
Licensed User
Longtime User
@@thedesolatesoul

I've tried to add some functionality to the jar where I could add my own ttf file (with icons from Icomoon). I wanted to then simply pass the character reference of the relevant icon. In my app I would have a lookup to give me a nice name for the icons. I managed to get the font changed over easily enough but am not good enough at java to add in a mechanism to do the character bit. So how much would you charge to add this functionality in, something like:
Dim icon As MSIconicDrawable
icon.Initialize("cic_f042")

cic would indicate that the customicons.ttf font should be used and the part after the underscore would correspond to the font code. Then ANY font file (well if it was renamed to customicons.ttf) could be used with this library...

Anyway, as said I'd be interested in knowing what you'd charge to modify for this purpose.

Regards

Jon
 

Chris Lee

Member
Licensed User

Using b4a 5.8, SDK 23 and I get the same. I'm using the MSMaterialDraw example and Icons only show in release compilation mode. I can live with this, since the icons are not fundamental to the debug process. Still would be nice to get em showing.
 

Chris Lee

Member
Licensed User
Hi all, wondering if anyone can help with a small issue I'm having. I've been attempting to splice the MSMaterialDrawer project with the appcompat tutorials.
I've managed to do this, but I'm having some trouble with the material drawer ending up white and the appcompat example not displaying checkboxes, possibly due to mixing themes.

In the manifest I have:

SetApplicationAttribute(android:theme, "@style/MaterialDrawerTheme.ActionBar")

But I also have the following line to handle the appcompat theming:

SetApplicationAttribute(android:theme, "@style/MyAppTheme")

This theme file in the resources folder is:

<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyAppTheme" parent="Theme.AppCompat">
<item name="colorPrimary">#b70d1d</item>
<item name="colorPrimaryDark">#b70d1d</item>
<item name="colorAccent">#b70d1d</item>
</style>
</resources>

Everything runs fine, my demo project will display dark material colors with red accents as desired. However the draw itself which was previously dark, is now light. In the main activity the checkboxes don't display.

If I don't build the draw with:

MD = MDB.Build

Then the main activity will now display fine.

White background with appcompat theme added:



Main activity with missing checkboxes when drawer is enabled:



Without building drawer:

 
Last edited:

Chris Lee

Member
Licensed User
OK, resolved these myself. Actually two issues. I was loading the main layout

Activity.LoadLayout("b4a4lay1")

After calling:

MD = MDB.Build

Which appears to remove the controls on the main form some reason.
By swapping these around, namely loading the main layout first, and then running MDB.build, it works fine.

As for the theme problem, I read around the subject a little more and found that I could use the custom theme provided in the resources.

In my case I altered

resource\md-app\res\values\styles.xml

Inside styles.xml I modified this section. The style name "CustomTheme" is important.

<style name="CustomTheme" parent="MaterialDrawerTheme.TranslucentStatus">
<!-- ...and here we setting appcompat’s color theme attrs -->
<item name="colorPrimary">#b70d1d</item>
<item name="colorPrimaryDark">#b70d1d</item>
<item name="colorAccent">#b70d1d</item>

Then I re-pointed to the custom style by going to the manifest and changing

SetApplicationAttribute(android:theme, "@style/MaterialDrawerTheme.ActionBar")

to

SetApplicationAttribute(android:theme, "@style/CustomTheme")


And removing the second style.

SetApplicationAttribute(android:theme, "@style/MyAppTheme")

This stuff is obvious now I understand it, just takes my brain a while.
 

Chris Lee

Member
Licensed User
I like the use of the MSIconicDrawable, it takes the pain out of creating icons. Also I was looking at the material design actionbar tutorial by Corwin. That uses bitmaps and I was wondering if I could use the MSIconicDrawable. I found a nice example on the forum that does it and turned it into a function.

pubic Sub MSIconicDrawableToBitmap(Icon as MSIconicDrawable) as Bitmap

Dim jo as JavaObject = Icon.Drawable
Dim bmp as Bitmap = job. RunMethod("toBitmap",null)

Return bmp

End Sub


You need to include the JavaObject library.

Now when adding menu items in the Corwin tutorial you can do things like

Dim s1 as MSIconicDrawable : s1.Initialize("gmd_settings") : s1.Color = 0xFFFF0018

Activity.AddMenuItem3("Plus one", "Menu", MSIconicDrawableToBitmap(s1), True)

Which I thought was useful.

I just wish now that I could solve the problem of the icons not appearing, marked with a cross, when in debug mode. I have read everything several times and my font files are correctly copied to project/Files/fonts
Works fine in release mode. Got to be some reason for it but I can't figure it.
 

DonManfred

Expert
Licensed User
Longtime User
Works fine in release mode. Got to be some reason for it but I can't figure it.
Have you tried using the following two commands in you main activity
B4X:
#DebuggerForceFullDeployment: true
#DebuggerForceStandardAssets: true
 

Chris Lee

Member
Licensed User
Have you tried using the following two commands in you main activity
B4X:
#DebuggerForceFullDeployment: true
#DebuggerForceStandardAssets: true

Thanks DonManfred, that fixed it. You are officially elevated to god like status! I can now make use of the icons whenever a bitmap it needed, this makes things a lot easier.
 

MarcoRome

Expert
Licensed User
Longtime User
Hi all
I have this picture ( Figure 2 ):



As you see i have icon on the left, i would like the central (as shown in figure 1):



This is my code:
B4X:
.....
Dim p1 As MSIconicDrawable : p1.Initialize("faw-sign-out"): p1.Color = Colors.ARGB(255, 255, 255, 255): p1.BackgroundColor = Colors.ARGB(255, 89,89,89 )
    Dim p2 As MSIconicDrawable : p2.Initialize("faw-comments-o"): p2.Color = Colors.ARGB(255, 255, 255, 255): p2.BackgroundColor = Colors.ARGB(255, 89,89,89 )
    Dim p3 As MSIconicDrawable : p3.Initialize("faw-users"):  p3.Color = Colors.ARGB(255, 255, 255, 255): p3.BackgroundColor = Colors.ARGB(255, 89,89,89 )
    Dim p4 As MSIconicDrawable : p4.Initialize("faw-newspaper-o"):  p4.Color = Colors.ARGB(255, 255, 255, 255): p4.BackgroundColor = Colors.ARGB(255, 89,89,89 )
    Dim p5 As MSIconicDrawable : p5.Initialize("faw-youtube-play"):  p5.Color = Colors.ARGB(255, 255, 255, 255): p5.BackgroundColor = Colors.ARGB(255, 89,89,89 )
    Dim p6 As MSIconicDrawable : p6.Initialize("faw-book"):  p6.Color = Colors.ARGB(255, 255, 255, 255): p6.BackgroundColor = Colors.ARGB(255, 89,89,89 )
    Dim p7 As MSIconicDrawable : p7.Initialize("faw-cogs"):  p7.Color = Colors.ARGB(255, 255, 255, 255): p7.BackgroundColor = Colors.ARGB(255, 89,89,89 )
    Dim p8 As MSIconicDrawable : p8.Initialize("faw-user-plus"): p8.Color = Colors.ARGB(255, 255, 255, 255): p8.BackgroundColor = Colors.ARGB(255, 89,89,89 )
.....

is there a way to centralize the same ??
Thank you
Marco
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…