B4A Library AHNavigationDrawer - Native Google Navigation Drawer

corwin42

Expert
Licensed User
This is a wrapper library for the native NavigationDrawer introduced by Google at Google I/O 2013.

It contains two objects:

AHNavigationDrawer - This implements the Navigation Drawer
SlideDrawable - This is a special type of drawable used to create an indicator for the NavigationDrawer
MaterialMenuDrawable - This is a drawable which can be used to create the Material Design burger->arrow->cross->check animation.

This Library uses the android-support-v4.jar library which is part of the Android SDK. You have to install it with the Android SDK Manager. In the SDK Manager please add/download the "Extras/Android Support" package. Then you will need to copy the android-support-v4.jar file from <SDK root folder>\extras\android\support\v4 to your B4A custom libs folder!
You need at least the API17 version of the library!

The MaterialMenuDrawable uses the NineOldAndroid animation library. Download the nineoldandroids-2.4.0.jar from here and place it in your custom libs folder (you don't need an xml file for it)

The example uses the mListView library by icefairy333 and the reflection library by agraham.

Changelog:
V1.0:
- Initial version

V1.1:
WARNING: Signature of the event subs have changed!
- Added support for secondary drawer
- Ability to change drawer edge touch sensitivity size

V1.20:
- Fixed the "glitch" while opening the drawer (Sometimes the drawer got "stuck" while swiping open)

V1.21:
- Fixed bug when using NavDrawer.ContentPanel.LoadLayout()

V1.30:
- Some internal changes which should make it compatible with ULV (Ultimate ListView)
- New MaterialMenuDrawable object for Material Design Burger/Arrow/Cross/Check animation
Attention: The MaterialMenuDrawable needs the NineOldAndroids library. See above.

V1.40:
- changed typo for nineoldandroids jar file (Name change: nineoldandroid-2.4.0.jar to nineoldandroids-2.4.0.jar). If you update from older version just change nineoldandroid-2.4.0.jar in your CustomLibs folder to nineoldandroids-2.4.0.jar

Screenshot_2013-08-01-09-49-05.png
 

Attachments

Last edited:

Theera

Well-Known Member
Licensed User
Hi CorWin42,

I've download all of Navigation Drawer zip files, and test with my emulator API 18. I've changed only manifest file as picture attached,but I 've error log file. it couldn't run.
 

Attachments

tipallandgo

Member
Licensed User
@Theera
I had experienced that error too. Copy your android-support-v4.jar again from the SDK. I can see that the creation date of that file in your additional libraries folder was on 2012. What you're using for B4A is outdated.

@corwin42 Thank you for this wonderful library. It's very useful for me. :D
 

Theera

Well-Known Member
Licensed User
Thank you ,tipallandro and Corwin42
 

AbbasMohammed

Member
Licensed User
Dear,
i couldn't run your Example, and the Err msg is (Compiling code. Error Unable to read beyond the end of the stream.), my version is 2.02, so is there a solution to overcome this problem???
 

Ionut Indigo

Member
Licensed User
AHNavigationDrawer is amazing and i will need to redesign my app, because this is a must have!
I'm having some problems, I'm running it on Android 2.3.5 and with the drawer opened, clicking (and holding) an item and trying to scroll (up/down), the background for the items goes black.
2013-08-22_18-58-43.jpg 2013-08-22_18-58-50.jpg 2013-08-22_18-58-58.jpg
This doesn't happen on Android 4+.
 

hypergreatthing

Member
Licensed User
AHNavigationDrawer is amazing and i will need to redesign my app, because this is a must have!
I'm having some problems, I'm running it on Android 2.3.5 and with the drawer opened, clicking (and holding) an item and trying to scroll (up/down), the background for the items goes black.
View attachment 19045 View attachment 19046 View attachment 19047
This doesn't happen on Android 4+.
It says it required API 17. That translates to jellybean 4.2.
I don't think you can run this on anything less than 4.2
 

corwin42

Expert
Licensed User
mListView (and the B4A standard ListView) have a ScrollingBackgroundColor property which defaults to black.
Try to set this color to the normal item color. If your item background is not a solid color set it to transparent.
 

corwin42

Expert
Licensed User
It would be possible and I will think about it. Currently it depends on the locale of the device. In "right to left" languages the drawer will open on the right side.
 

tipallandgo

Member
Licensed User
Hi again! I just wanna ask for your opinion. If I'm going to use this for my app, would you recommend using a single Activity with multiple panels instead of multiple Activities with navigation drawers in each one?
 

Ionut Indigo

Member
Licensed User
Hi again! I just wanna ask for your opinion. If I'm going to use this for my app, would you recommend using a single Activity with multiple panels instead of multiple Activities with navigation drawers in each one?
Hi tipallandgo,
I was wondering the same thing when i started using AHNavigationDrawer, and I'm developing my app with one drawer and multiple panels, and also other activities with no drawer.
 

Inman

Well-Known Member
Licensed User
The library works great for me. I am starting a new project and will be using it.

The only issue I have is regarding the difficulty to open the Nav Drawer with the swipe gesture. I mean you need to swipe very very close to the left edge of the screen to open the drawer. This is particularly problematic if you are using the phone one-handedly with your left hand. When I try to open it with my left thumb, I rarely succeed. Please try it yourself.

I first thought it was an issue with Google's implementation in android-support-v4.jar. Then I tried some Google apps like YouTube and Gmail and noticed that I could open the nav drawer with the left thumb, every single time. I believe you need to increase the area from the left edge where you wait for the gesture (Google recommends at least 20dip). Could you please take a look?
 

corwin42

Expert
Licensed User
The only issue I have is regarding the difficulty to open the Nav Drawer with the swipe gesture. I mean you need to swipe very very close to the left edge of the screen to open the drawer. This is particularly problematic if you are using the phone one-handedly with your left hand. When I try to open it with my left thumb, I rarely succeed. Please try it yourself.

I first thought it was an issue with Google's implementation in android-support-v4.jar. Then I tried some Google apps like YouTube and Gmail and noticed that I could open the nav drawer with the left thumb, every single time. I believe you need to increase the area from the left edge where you wait for the gesture (Google recommends at least 20dip). Could you please take a look?
The AHNavigationDrawer library is just a wrapper to the DrawerLayout Class. There is no parameter to change this area size. All is handled internally by this class.
 

Inman

Well-Known Member
Licensed User
Oh ok. Could you please checkout on your phone and see if the experience is like I mentioned? I just want to know if the issue is peculiar to my phone (Galaxy Note N7000 running Android 4.2.2 CM10 build).
 

corwin42

Expert
Licensed User
Yes, it seems that the Navigation Drawer of the example is sometimes "harder" to open than in other (Google) apps. I have no idea, why. Maybe they don't use the implementation of the support.library but their own? I really don't know.
 
Top