B4A Library AHNavigationDrawer - Native Google Navigation Drawer

corwin42

Expert
Licensed User
Longtime User

Yes. Everything you have added to the activity before using the NavigationDrawer now should be added to the ContentPanel. The ContentPanel "replaces" the Activity if you use NavigationDrawer.
 

Inman

Well-Known Member
Licensed User
Longtime User
Will it be possible to implement a "semi-open" state for the NavDrawer? I would like to display a small visible edge of the drawer (like 30 or 40dip) so that the user will know there is a drawer to slide out. This is particularly useful when the drawer is on the right side as such drawers don't have the sliding icon indicator.

There is a discussion at StackOverflow on this topic:
http://stackoverflow.com/questions/6259706/slidingdrawer-semi-opened-on-start
 

corwin42

Expert
Licensed User
Longtime User

In the StackOverflow discussion they talk about the deprecated SlidingDrawer class. AHNavigationDrawer uses the newer NavigationDrawer class so the stackoverflow solution won't work here.
 

brelto85

Active Member
Licensed User
Longtime User
I've added the AHNavigationDrawer into my app
in activity_create i have the follow code:

B4X:
...
Activity.LoadLayout("LayoutMain")
mNavigationDrawer.Initialize("Drivi - Drive Safely", "logo.png", True, Colors.ARGB(127, 54, 180, 215), "Light", True, True, True, wOverflowItems, "Drawer", Activity, Me)
...

All the views added with the designer doesn't work
I've a button added with designer and the click event not fired

if i delete the NavigationDrawer the click event works fine
where is the problem?
 

corwin42

Expert
Licensed User
Longtime User

Don't load your layout to the activity.

Add the NavigationDrawer object to the activity.
Load your Layout to the NavigationDrawer.ContentPanel.

See the example of how to add the views correctly.
 

brelto85

Active Member
Licensed User
Longtime User
So, i don't need to use Activity.LoadLayout("LayoutMain")
I must add each views programmatically using the ContentPanel?
With complex views, is not very convenient

In the example you use this:

NavDrawer.ContentPanel.AddView(Pages(i), ...) where the Pages(i) is a list of panels
 

brelto85

Active Member
Licensed User
Longtime User
Perfect
I add that after the Initialize method
It works but some views are positioned in a incorrect position in relation with the Designer
There are some rules for position?
 

brelto85

Active Member
Licensed User
Longtime User
Now i don't have my pc with me
I can try to explained in more detail

In the designer i've added a ImageView and i positioned it in center screen

Following your suggestions, i write this code:

B4X:
...
mNavigationDrawer.Initialize("Drivi - Drive Safely", "logo.png", True, Colors.ARGB(127, 54, 180, 215), "Light", True, True, True, wOverflowItems, "Drawer", Activity, Me)
mNavigationDrawer.NavDrawer.ContentPanel.LoadLayout("LayoutMain")
...

when start the application, the ImageView control is positioned in a 0,0 axis
 

corwin42

Expert
Licensed User
Longtime User
when start the application, the ImageView control is positioned in a 0,0 axis

I see.

Download Version 1.21 in the first post of this thread. This should fix the problem.
 

corwin42

Expert
Licensed User
Longtime User
Also, do you know why the NavDrawer is preventing listview scrolling?
Attached is a small example of the problem I see.

Don't add your content to the Activity or the Panel that contains the NavDrawer. Add your content to the NavDrawer.ContentPanel like

B4X:
NavDrawer.ContentPanel.AddView(pContent, 0 ,0, 100%x, 100%y)

You can even add the NavDrawer directly to the Activity so you don't need the pDrawer Panel

B4X:
NavDrawer.Initialize("NavDrawer", Activity, 240dip)
 

corwin42

Expert
Licensed User
Longtime User
Could you please add setScrimColor?
Also, what is the shadow drawable?
Thanks.

Will add it to the next version. Until then you can use it with reflection library.

B4X:
Sub SetScrimColor(Nav As AHNavigationDrawer, Color As Int)
    Dim r As Reflector
    r.Target = Nav
    r.Target = r.GetField("mNavDrawer")
    r.RunMethod4("setScrimColor", Array As Object(Color), Array As String("java.lang.int"))   
End Sub

The shadow drawable is for a small shadow right to the drawer.
 

thedesolatesoul

Expert
Licensed User
Longtime User
Thank you
It took a while for me to understand in the hierarchy of views, but now I understand the NavDrawer actually attaches inside a panel and takes its gestures. It works now.

Thank you again
It is working as expected. I didnt know reflection could access private fields as well.
 

brelto85

Active Member
Licensed User
Longtime User
I notice that the views included into the NavDrawer.ContentPanel, doesn't saved from StateManager library
How to handle the state of these views
 

corwin42

Expert
Licensed User
Longtime User
I notice that the views included into the NavDrawer.ContentPanel, doesn't saved from StateManager library
How to handle the state of these views

You have to handle the state yourself or you can expand statemanager class that it can handle the contentpanel of the NavDrawer.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…