Skip to content
This repository has been archived by the owner on Apr 30, 2020. It is now read-only.

Functionalities

Fabio Biola edited this page Mar 22, 2015 · 6 revisions

Learning Pattern

When the Activity starts, the drawer will be open automatically for let the users to know that there is a navigation drawer. It seems like pretty obvious to us, but there are some users that must be taught to do that (unfortunatelly).

Statically, add this line in your navigation drawer theme:

<!-- alpha, ufficially released from 1.3.3 -->
<item name="learningPattern">false</item>

Programmatically, add this code to your init() method:

this.disableLearningPattern();

Back Pattern

There are a lot of methods for use the back button. Actually this library supports these patterns:

  • Back Anywhere (default)
    (if user click on back button, the activity will close)
  • Back to first
    (if user click on back button, the content change to the first section fragment)
  • Custom backpattern
    (see below)

for setting the pattern add in your init this code:

setBackPattern(MaterialNavigationDrawer.BACKPATTERN_BACK_TO_FIRST);
BACKPATTERN_CUSTOM:

When you use this backpattern you should override this method in your MaterialNavigationDrawer Activity:

@Override
    protected MaterialSection backToSection(MaterialSection currentSection) {
        // example of use:
        if(currentSection == night) {
            return last;
        }

        if(currentSection == last) {
            return section1;
        }
        return super.backToSection(currentSection);
    }

if you have some pattern to suggest please comment on this issue, thanks.

Multipane

multi pane support makes the drawer always open on the left, but only with tablet in landscape mode.
Statically, add this line in your navigation drawer theme:

<item name="multipaneSupport">true</item>

Programmatically, add this method to your init()

addMultiPaneSupport();

Default Section Loaded

You can override the first section that is loaded when the navigation drawer starts.
Statically, add this line in your navigation drawer theme:

<item name="defaultSectionLoaded">0</item>
<!-- 0 is default for the first, 1 for second etc. -->

Programmatically, add this method to your init()

setDefaultSectionLoaded(0);

NOTE the section number starts from 0.

Enable Action Bar Shadow / Toolbar Elevation

Statically, add this line in your navigation drawer theme:

<item name="toolbarElevation">true</item>

Programmatically, add this method to your init()

enableToolbarElevation();