B4A Library MSMaterialMenu - Animating icons

This library simulates some animations on the drawer icon on the titlebar that are coming in on the material design.
It comes from this library: https://github.com/balysv/material-menu

68747470733a2f2f7261772e6769746875622e636f6d2f62616c7973762f6d6174657269616c2d6d656e752f6d61737465722f6172742f64656d6f2e676966


Dependencies:
- The NineOldAndroid java package, is included in the zip file.

Credits:
Thanks to Informatix for his NineOldAndroids library and for modifying it for me.

Sample:
B4X:
    Dim StdABHelper As StdActionBarHelper
    Dim MMenu As MSMaterialMenu
    StdABHelper.Initialize
    MMenu.Initialize("MMenu")

    MMenu.setScaleAndStroke(1,2)
    MMenu.Color = Colors.Black
    StdABHelper.Icon = MMenu.Drawable


Sub StdAB_ButtonClicked
    If MMenu.State = "BURGER" Then
        MMenu.animatePressedState("X")
        NavDrawer.OpenDrawer
    Else
        MMenu.animatePressedState("BURGER")
        NavDrawer.CloseDrawer
    End If
End Sub

This will work best with StdActionBar+StdActionBarHelper (wish they were merged).
 

Attachments

  • MSMaterialMenu.zip
    119.5 KB · Views: 2,540
Last edited:

SCIS

Active Member
Licensed User
Longtime User
@thedesolatesoul Unfortunatly I can only debug when the debugger is set to Release, I don't know why and I know it sounds weird but that means I can't see logs right? I don't think it's a problem with the library, just something I'm doing wrong. I've been trying to implement a lot of Slidingmenu's in the app but none of them have seemed to be able to work with the animation so far. I mean I do get the animation to work but just not when the user slides the menu open without pressing the button.
 

thedesolatesoul

Expert
Licensed User
Longtime User
@thedesolatesoul Unfortunatly I can only debug when the debugger is set to Release, I don't know why and I know it sounds weird but that means I can't see logs right? I don't think it's a problem with the library, just something I'm doing wrong. I've been trying to implement a lot of Slidingmenu's in the app but none of them have seemed to be able to work with the animation so far. I mean I do get the animation to work but just not when the user slides the menu open without pressing the button.
I always use Release. You can see the Logs if you are connected via USB.

So if you want to use see the animation changing AS the user slides, just see a few posts up, I JUST replied to this EXACT query.
 

migrec

Member
Licensed User
Longtime User
I can't compile your code since there are activities and services connected to it that i dont have, however i can help you here.

You can remove these subs (as you don't use them):
B4X:
Sub StdAB_ButtonClicked
    CallSub(Null, ClickCloseDrawer)
End Sub
and..
B4X:
Sub NavDrawer_DrawerOpened (DrawerGravity As Int)
    'MMenu.animatePressedState("X")'Test
    MMenu.animateState("X")
    'Navdrawer.OpenDrawer
    isDrawerOpened = True
End Sub

Sub NavDrawer_DrawerClosed (DrawerGravity As Int)
    'MMenu.animatePressedState("BURGER")'Test
    MMenu.animateState("BURGER")
    'Navdrawer.CloseDrawer
    isDrawerOpened = False
End Sub
Now change following:
B4X:
Sub NavDrawer_DrawerSlide (Position As Float, DrawerGravity As Int)
    Dim slideOffset As Float
   
    Log(Position)

    'If Navdrawer.isDrawerOpen Then
    If isDrawerOpened Then
        slideOffset = 2 - Position
    Else
        slideOffset = Position
    End If
    MMenu.setTransformationOffset("BURGER_ARROW", slideOffset)
End Sub
to just:
B4X:
Sub NavDrawer_DrawerSlide (Position As Float, DrawerGravity As Int)
    Dim slideOffset As Float
    If NavDrawer.IsDrawerOpen Then
        slideOffset = 2 - Position
    Else
        slideOffset = Position
    End If
    MaterialIcon.setTransformationOffset("BURGER_ARROW", slideOffset)
End Sub
And in this sub:
B4X:
Sub lv1_ItemClick (Position As Int, Value As Object)
just add:
B4X:
NavDrawer.CloseDrawer

Dont know if this will work for you since it's pretty hard to tell without being able to compile...
 

SCIS

Active Member
Licensed User
Longtime User
Thanks for all the help so far guys, I've been trying to make some changes to my project so I can send it completely to you but it's not working, I can't get it to debug when I make these changes, this might have something to do with the fact that we're using the Google Maps library with a private sign key... @thedesolatesoul I know that you have answered the question a couple of post earlier, I think that part is working but I just can't seem to get the AHNavigationDrawer to work. Can someone perhaps post an example project with that part that's working? Maybe I can fix it from there on myself. Anyways, thanks for the help @migrec and @thedesolatesoul.
 

SCIS

Active Member
Licensed User
Longtime User
I can't seem to get your example working :( The application crashes right after it is installed. Here's the log with the error message I get.
 

Attachments

  • Log.txt
    2 KB · Views: 285

migrec

Member
Licensed User
Longtime User
Now it's starting to get weird, try running in debug and find the line causing the error.
 

SCIS

Active Member
Licensed User
Longtime User
Great news! finally found the problem! I had to re-download and replace the "android-support-v4" library through the SDK manager again. Thanks for everything!
 

mat2175

Member
Licensed User
Longtime User
Has anyone managed to get the DialogBuilder to work i keep getting an error:

Error occurred on line: 912 (main)
android.content.res.Resources$NotFoundException: Resource ID #0x0
at android.content.res.Resources.getValue(Resources.java:2329)
at android.content.res.Resources.getDimensionPixelSize(Resources.java:1738)
at com.r0adkll.postoffice.styles.EditTextStyle.applyDesign(EditTextStyle.java:56)
at com.r0adkll.postoffice.model.Delivery$Builder.setStyle(Delivery.java:765)
at com.maximussoft.materialdialogs.BuilderWrapper.setEditTextStyle(BuilderWrapper.java:259)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:680)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:308)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:238)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:121)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:175)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:171)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:77)
at android.view.View.performClick(View.java:5156)
at android.view.View$PerformClick.run(View.java:20755)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5832)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
 

jahswant

Well-Known Member
Licensed User
Longtime User
Is there a way to implement a tree view like on the drawer i know it's not the right place to post this question ???I want to implement categories and products ...
 

jahswant

Well-Known Member
Licensed User
Longtime User
Which library would i use is there a tutorial or a snippet that you ca point me to it ?
 

thedesolatesoul

Expert
Licensed User
Longtime User
Which library would i use is there a tutorial or a snippet that you ca point me to it ?
Nope, I'm not aware of a satisfactorily easy/fast expandable listview library.
You can try the UltimateListView which can do anything, but it will take some effort to build the expandable logic yourself. For e.g. there is a Tree Demo, if you look here.
 

Haris Hafeez

Active Member
Licensed User
Longtime User
Hey everybody,

I'm looking to use the icon fonts to draw the icons for my menu items. How to go about doing it? The drawable that MSIconicDrawable returns does not let me access to a bitmap which is what the Activity.AddMenuItem3 demands as a parameter.

Any tips on how to use it? Or is it not recommended?

Thanks.
 
Top