Giter VIP home page Giter VIP logo

materialnavigationdrawer's People

Contributors

neokree avatar philbring avatar wlsc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

materialnavigationdrawer's Issues

Hiding OptionsMenu (icons) when the drawer is opened

OptionsMenu should be hidden (gone) when the drawer is opened (so toolbar icons will disappear) and recovered when closed (see GMail app for example).

More complicated cases are when a toolbar is changed e.g. multiselect is triggered or search in toolbar is present. In this case, original toolbar without menu icons should appear back when the drawer is opened and specialized multiselect / search / however previously changed toolbar should re-appear when closed back. Try to multiselect some items in GMail app, open/close the drawer & you will see it in action ;)

UPDATE: from GMail app
toolbar-menu

unchecked call warning

"Unchecked call to newSection(String, Drawable, Fragment) as a member of raw type"

How to resolve this warning?

Do you have plan to integrate Tabs into the section of Drawer

I found you implement the Drawer and Tab modules in separate projects. In real project, I need the Tabs to support the sub-category views of the main category in the Drawer. And also there are several apps using this models.
So what's your consideration and plan. Thanks.

Why I cannot override onCreate method?

We can just extend one superclass. Most people extend ActionBarActivity (AppCompat) in order to use the new Toolbar widget. If we can't extend it, we will probably be unable to use the toolbar.
Also, it's much easier to implement the required methods under onCreate(), rather than under init().

Drawer below the toolbar

Is there way to show navigation drawer below the toolbar? I can't see the arrow drawable while drawer opening.

There are some example of views; https://github.com/kanytu/android-material-drawer-template

It would be great if i choose one of these layouts in my code like;
setDrawerStyle(DrawerStyle.Default);
setDrawerStyle(DrawerStyle.GoogleInbox);
setDrawerStyle(DrawerStyle.PlayStore);
setDrawerStyle(DrawerStyle.Gmail);

and if there was an option to hide profile pic like showProfileImage(false);
also resizing the drawer background would be greak like; http://i.stack.imgur.com/aj5dU.png

I can modify your lib if you are busy send it back to you.

Thanks

Bottom section pinning

According to material design specification:
http://www.google.com/design/spec/patterns/navigation-drawer.html
there is no such thing as a bottom pinned section.

From the spec:
"Settings and support are located at the bottom of the scrolling list, in-line with the rest of the list content."
Inline = following the last items in drawer, not pinned to the bottom - see Google apps.

From the specification - if the list of items in drawer is short:
"If the list doesn’t scroll, the settings and support items will appear at the end of the list and are not pinned."

But it might be OPTIONALY pinned, if a list of items is very long, from the spec:
"If the list of content in the navigation drawer is very long, the two options can be pinned to the bottom of the navigation drawer on a surface with a higher elevation. This surface is present only while at the top of the list; any other scroll position will immediately result in dismissing the surface and placing the options at the end of the list, in-line with the rest of the list content. The navigation drawer retains its scroll position when closed and reopened."

So pinning to bottom is OPTIONAL only in case of so many items that scrolling is enabled (but not even Google apps does that). Moreover, in this very specific OPTIONAL scenario, it should appear pinned only when not scrolled, and dissappear while scrolling.

Roboto font in the drawer (and toolbar)

Well, as per spec Roboto font should be used everywhere in the drawer (by def). However, setting font's isn't esiest in Android - usually done thru extending original Views classes, creating (libs with) custom ones. Everybody does it differently, some use libraries, some handle it in their app alone...

Thus, it would be gr8 to let implementation use the most commond Roboto libs like:
https://github.com/johnkil/Android-RobotoTextView
https://github.com/eeVoskos/RobotoViews
or use developer provided font resource internally in lib, avoiding unnecessary, possibly duplicate assets (if utilizing own font as asset in lib). If lib / font asset would not be provided (developer doesn't care), default font might be used as now.

transparency and material guidelines

I am reading through the new Material Design Spec and the Material Design Checklist.
The spec says that the slide out pane should float above everything else including the status bar and be semi-transparent over the status bar.
From the screenshots of your implementation it doesn't look like it has transparency.. I just wanted to know if that is left to the user to implement or is something you still have to implement yourself?

thanks for the help,

Issue with MaterialSectionListener

Hello!

I just want to start by saying that this is an awesome library. The first I've seen to actually get the specs right and the methods you've implemented are really making my life a breeze. :)

Anyway, I need to use a section with a MaterialSectionListener and tried this:

this.addSection(this.newSection("Title", new MaterialSectionListener() {
    @Override
    public void onClick(MaterialSection section) {
        // Doing some stuff here, then opening another activity
    }
}));

However, that throws this exception:

java.lang.RuntimeException: Fragment must be android.app.Fragment or android.support.v4.app.Fragment
at it.neokree.materialnavigationdrawer.MaterialNavigationDrawer.setFragment(MaterialNavigationDrawer.java:397)
at it.neokree.materialnavigationdrawer.MaterialNavigationDrawer.onClick(MaterialNavigationDrawer.java:566)
at it.neokree.materialnavigationdrawer.MaterialSection.onTouch(MaterialSection.java:107)

Is this me missing something obvious or is it a bug? 😄

Change in Model

Hi,

I'm trying to implement this library in my product, but for implementing your library I need to use MaterialDrawer class but my product already has it's own classes which inherit the ActionBarActivity class.

So can this library have a different model, I mean a Decoupled model

Replace android.support.v4.app.Fragment with android.app.Fragment

I'm having trouble getting a working copy of my clone of this project to edit it myself. Since the project has a minimum version of 14 there's no reason to use support fragments and just use android.app.Fragment instead. Since my settings fragment is based on PreferenceFragment, I can't launch it using the navigationdrawer. PreferenceFragment didn't make it into the support library.

Dark toolbar/actionbar color

Hi,
I am using a dark colorPrimary, and the elements in the toolbar are black, while they should be white to contrast with the dark toolbar. Also the title and any menu actionviews are black. I guess this is because your parent theme is set to Light? Would it be possible to have also a dark implementation of your library? Or can you suggest what I could do to remedy the issue?

thanks!

burger icon to arrow animation

This animation of drawer icon shouldn't happen in case of navigation drawer, because drawer goes on top of "actionbar" so that animating its icon is meaningless.
Not even the latest versions of Google apps do this anymore (some did it previously, mistakenly).
screenshot_2014-12-20-22-59-11

Fragments overlapping?

Hello again,
I implemented your library mostly successfully (thanks, you are doing a great job btw) but when I replace the FragmentIndex of your example with 3 different fragments, what I see is that the fragments overlap? So I can still see fragment1 when I should only see fragment2. You don't see that in your example code because your fragments are all instances of FragmentIndex, so they are identical.
In your implementation, are the fragments added, or are they replacing previous fragments?

thanks for the clarification!

bug report - RuntimeException

java.lang.RuntimeException: Unable to start activity ComponentInfo{it.neokree.materialnavigationdrawer/it.neokree.example.MainActivity}: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment it.neokree.example.MainActivity$FragmentIndex: make sure class name exists, is public, and has an empty constructor that is public
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2110)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)
at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3576)
at android.app.ActivityThread.access$800(ActivityThread.java:140)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1243)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4921)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment it.neokree.example.MainActivity$FragmentIndex: make sure class name exists, is public, and has an empty constructor that is public
at android.support.v4.app.Fragment.instantiate(Fragment.java:431)
at android.support.v4.app.FragmentState.instantiate(Fragment.java:101)
at android.support.v4.app.FragmentManagerImpl.restoreAllState(FragmentManager.java:1823)
at android.support.v4.app.FragmentActivity.onCreate(FragmentActivity.java:264)
at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:122)
at it.neokree.materialnavigationdrawer.MaterialNavigationDrawer.onCreate(MaterialNavigationDrawer.java:70)
at android.app.Activity.performCreate(Activity.java:5206)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2074)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)
at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3576)
at android.app.ActivityThread.access$800(ActivityThread.java:140)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1243)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4921)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.InstantiationException: can't instantiate class it.neokree.example.MainActivity$FragmentIndex; no empty constructor
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1319)
at android.support.v4.app.Fragment.instantiate(Fragment.java:420)
at android.support.v4.app.FragmentState.instantiate(Fragment.java:101)
at android.support.v4.app.FragmentManagerImpl.restoreAllState(FragmentManager.java:1823)
at android.support.v4.app.FragmentActivity.onCreate(FragmentActivity.java:264)
at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:122)
at it.neokree.materialnavigationdrawer.MaterialNavigationDrawer.onCreate(MaterialNavigationDrawer.java:70)
at android.app.Activity.performCreate(Activity.java:5206)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2074)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)
at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3576)
at android.app.ActivityThread.access$800(ActivityThread.java:140)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1243)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4921)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)

Full screen

Hi,

I am working on a full screen app.
Can i use this lib with out action bar ?

Thanks

API 10 support

There are only few methods that doesn't support API 10, and they are easy to backport.
Check this:
https://github.com/yoavst/MaterialNavigationDrawer/commit/4fef353f693f4183a7855f5159362427feeaeb31

// Somewhere in the code you get the height, so you can use that.
int getHeight() {
        int height = 0;
        Display display = getWindowManager().getDefaultDisplay();
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
            Point size = new Point();
            display.getSize(size);
            height = size.y;
        } else {
            height = display.getHeight();  // deprecated
        }
        return height;
    }
// When you set alpha, use that method.
    void setAlpha(View v, float alpha) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            v.setAlpha(alpha);
        } else {
            AlphaAnimation animation = new AlphaAnimation(alpha, alpha);
            animation.setDuration(0);
            animation.setFillAfter(true);
            v.startAnimation(animation);
        }
    }

And on versions lower then v11, just don't do the animation:

private void switchAccounts(final MaterialAccount newAccount) {
        final ImageView floatingImage = new ImageView(this);
        // si calcolano i rettangoli di inizio e fine
        Rect startingRect = new Rect();
        Rect finalRect = new Rect();
        Point offsetHover = new Point();
        // 64dp primary user image / 40dp other user image = 1.6 scale
        float finalScale = 1.6f;
        final int statusBarHeight;
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
            statusBarHeight = (int) (25 * density);
        } else {
            statusBarHeight = 0;
        }
        // si tiene traccia della foto cliccata
        ImageView photoClicked;
        if (newAccount.getAccountNumber() == MaterialAccount.SECOND_ACCOUNT) {
            photoClicked = userSecondPhoto;
        } else {
            photoClicked = userThirdPhoto;
        }
        photoClicked.getGlobalVisibleRect(startingRect, offsetHover);
        floatingImage.setImageDrawable(photoClicked.getDrawable());
        // si aggiunge una view nell'esatta posizione dell'altra
        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(photoClicked.getWidth(), photoClicked.getHeight());
        params.setMargins(offsetHover.x, offsetHover.y - statusBarHeight, 0, 0);
        drawer.addView(floatingImage, params);
        // si setta la nuova foto di profilo sopra alla vecchia
        photoClicked.setImageBitmap(currentAccount.getCircularPhoto());
        // si setta la nuova immagine di background da visualizzare sotto la vecchia
        usercoverSwitcher.setImageBitmap(newAccount.getBackground());
        userphoto.getGlobalVisibleRect(finalRect);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
            // Si calcola l'offset finale (LARGHEZZA DEL CONTAINER GRANDE - LARGHEZZA DEL CONTAINER PICCOLO / 2) e lo si applica
            int offset = (((finalRect.bottom - finalRect.top) - (startingRect.bottom - finalRect.top)) / 2);
            finalRect.offset(offset, offset - statusBarHeight);
            startingRect.offset(0, -statusBarHeight);
            // si animano le viste
            AnimatorSet set = new AnimatorSet();
            set
                    // si ingrandisce l'immagine e la si sposta a sinistra.
                    .play(ObjectAnimator.ofFloat(floatingImage, View.X, startingRect.left, finalRect.left))
                    .with(ObjectAnimator.ofFloat(floatingImage, View.Y, startingRect.top, finalRect.top))
                    .with(ObjectAnimator.ofFloat(floatingImage, View.SCALE_X, 1f, finalScale))
                    .with(ObjectAnimator.ofFloat(floatingImage, View.SCALE_Y, 1f, finalScale))
                    .with(ObjectAnimator.ofFloat(userphoto, View.ALPHA, 1f, 0f))
                    .with(ObjectAnimator.ofFloat(usercover, View.ALPHA, 1f, 0f))
                    .with(ObjectAnimator.ofFloat(photoClicked, View.SCALE_X, 0f, 1f))
                    .with(ObjectAnimator.ofFloat(photoClicked, View.SCALE_Y, 0f, 1f));
            set.setDuration(USER_CHANGE_TRANSITION);
            set.setInterpolator(new DecelerateInterpolator());
            set.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    onSwitchAcountAnimationEnd(newAccount, floatingImage);
                }

                @Override
                public void onAnimationCancel(Animator animation) {
                    // se si annulla l'animazione si conclude e basta.
                    onSwitchAcountAnimationEnd(newAccount, floatingImage);
                }
            });
            set.start();
        } else onSwitchAcountAnimationEnd(newAccount, floatingImage);
    }

    void onSwitchAcountAnimationEnd(MaterialAccount newAccount, ImageView floatingImage) {
        // si carica la nuova immagine
        setAlpha(userphoto, 1);
        setFirstAccountPhoto(newAccount.getCircularPhoto());
        // si cancella l'imageview per l'effetto
        drawer.removeView(floatingImage);
        // si cambiano i dati utente
        setUserEmail(newAccount.getSubTitle());
        setUsername(newAccount.getTitle());
        // si cambia l'immagine soprastante
        setDrawerBackground(newAccount.getBackground());
        // si fa tornare il contenuto della cover visibile (ma l'utente non nota nulla)
        setAlpha(usercover, 1);
        // switch numbers
        currentAccount.setAccountNumber(newAccount.getAccountNumber());
        newAccount.setAccountNumber(MaterialAccount.FIRST_ACCOUNT);
        // change pointer to newAccount
        currentAccount = newAccount;
        // si chiude il drawer
        if (!deviceSupportMultiPane())
layout.closeDrawer(drawer);
    }

back button support

Hi,

First, I want to thank you for doing such a great work. This lib is great and helps a lot.
I encountered few issues when using back button,
Please take a look at the following if possible:

  1. If I exit the app with back button, the next time I start the app causes a crash
  2. Using back button will exit the app, instead of getting back to the previous screen (in google apps, the behavior is to get back to the main screen, then another "back" press leads to app exit)
  3. Opening a new fragment from the drawer (like settings fragment), then hitting back, will cause us to get back to the previous screen as it should, however, the selected list item will still be settings, instead of the previous item selected.

One more small issue here, not related to back button, is RTL support. It will be nice to have this feature (explained at http://android-developers.blogspot.co.il/2013/03/native-rtl-support-in-android-42.html). Essentialy, there are two steps involved:
adding android:supportsRtl="true" to the element in manifest file
and changing (or adding if min sdk is lower than 17) "start" instead of "left" and "end" instead of right.

Thanks again,
Yaniv

Sections with custom defined onClick actions

Admirably, nav drawer is just not only for setting fragments / activities.

There are TON of use cases when app needs to have some custom logic and based on it, decide what will be done. E.g. sometimes, I need to check if there is added user / items I want to show so I trigger usual fragment, or just show placeholder, dialog or sth. Also Google apps need that - they trigger dialogs, open websites in some cases, trigger activity for result or some need to react if user has a conenction or not etc... list goes on and oooon.

More flexibility is clearly needed for an action which happens on drawer item click (selected) to allow user define custom action.

SOLUTION:
Currently because of that, I use an older version of a lib as a project mobule lib :-/ with a custom section constructors, custom section listener (extending the same MaterialSectionListener you already have) and I set it like section.setCustomOnClickListener and have some more logic to handle that... If set, I trigger this listener at the end of onClick impl in MaterialNavigationDrawer class, of course, not setting a new frag / activity previously, but letting a developer to do what's needed.

@neokree I would like to contribute to solve this, as this is almost the BIGGEST limitation this lib now has & it would be great to solve it asap. My approach doesn't have to be the best, but it works and it's kinda easy. Do not hesitate to contact me directly to figure this out (and also to test your newest features / imporvements before releasing them) ;)

Selected menu items remain highlighted

Hi!

First of all, thank you for your great job.

I came across a little problem while implementing this drawer.
When I declare sections inside addSection(), no problem.

But when I try to declare them beforehand as the following:

//create sections and associated fragments
mainSection = this.newSection("Home", getResources().getDrawable(R.drawable.ic_home_grey600_48dp), new MainFragment());
pendingShares = this.newSection("Pending shares",getResources().getDrawable(R.drawable.ic_database_grey600_48dp),new PendingSharesFragment()).setNotifications(10);
shareSection = this.newSection("Share", this.getResources().getDrawable(R.drawable.ic_share_grey600_48dp), new ShareFragment()).setSectionColor(Color.parseColor("#2196f3"));
alarmSection = this.newSection("Alarms",getResources().getDrawable(R.drawable.ic_alarm_grey600_48dp), new AlarmFragment()).setSectionColor((Color.parseColor("#ff9800")));
profileSection = this.newSection("Profile", getResources().getDrawable(R.drawable.ic_account_grey600_48dp), new ProfileFragment());
settingsSection = this.newBottomSection("Settings",this.getResources().getDrawable(R.drawable.ic_cog_grey600_48dp),new Intent());

// add sections
this.addSection(mainSection);
this.addSection(pendingShares);
this.addSection(shareSection);
this.addDivisor();
this.addSection(alarmSection);
this.addSection(profileSection);
this.addBottomSection(settingsSection);

the drawer items remain highlighted when I navigate between sections.

screenshot_2014-12-17-17-11-50

Should I instantiate sections manually using new MaterialSection()?

No account drawer

There are apps that don't need a user to be logged in. In such case, in "account area" there is just a text of a size "abc_text_size_headline_material" - usually by def white, with some background, usually only a color (accent in some apps). Nothing else, pretty simple.

Suggestion: add style Light.DarkActionbar

Because the library doesn't allow you to directly change the Toolbar in XML I had to change my style in order to have a light theme with a Dark Actionbar. The following style could be used to implement such a feature.

<style name="MaterialNavigationDrawerTheme.Light.DarkActionbar" parent="Theme.AppCompat.Light">
        <item name="android:windowTranslucentStatus">true</item>
        <item name="windowActionBar">false</item>
        <item name="theme">@style/ThemeOverlay.AppCompat.Dark.ActionBar</item>
        <item name="popupTheme">@style/Base.V21.Theme.AppCompat.Light.Dialog</item>
        <item name="android:textColorSecondary">@android:color/white</item>
    </style>

The problem with this is that <item name="android:textColorSecondary">@android:color/white</item> will still be global but it's better than nothing.

this.getSupportActionBar() returns null in init()

this.getSupportActionBar()

returns null in init() when called in a class extending MaterialNavigationDrawer

Note:

I was able to call it in

onPostCreate(Bundle savedInstanceState)

but normally you should be able to call this in onCreate().

colorPrimaryDark as statusbar background

I know it's a choice from you to let the statusbar background (colorPrimary) be tinted with the translucent filter of KitKat statusbar.
But I think that colorPrimaryDark as background feels more like Lollipop devices, even when tinted.

Navigation drawer below the toolbar

Hello,
You really did a great job with this library, this made the app code much more clearer and with minimal boilerplate code, thank you for that :)
Want to ask if there's an option to allow the side drawer to go under the toolbar, or are you planning to add it. I previously have done this by adding a top margin to the drawer layout view with heigh equals to the actionbar size. Many of Google apps are still doing this this way even though they're update to the material design (like the new Calendar app or the Google drive app for instance), and I prefer it this way personally.

Clickable username, photo and email

How doing this elements (username, photo and email) clickable, for opening my Profile Fragment ?
Like as Section, but with this elements ↑

Sample screen (red - clickable)
Image by N1cE™

Gradle, please

Is it possible to have the library uploaded to Maven Central ?

Subeheader (non-clickable section item)

As per spec (and also seen in Google apps like GMail or Inbox), drawer allowes subheaders:
http://www.google.com/design/spec/patterns/navigation-drawer.html
Subheader: Roboto Medium, 14sp, 54% #000000. Aligns to the 16dp keyline.

It has special alignment, no icon, no clickable / selectable state (pure TextView is enough).
It could be found only just below a sections divider to tell the new section name or describe its following content / purpose. Usually it's used for specific or user defined sections, not the main navigation / first section, but to tell content / sections apart in longer nav drawers.

Landscape mode

In landscape mode, drawer width is totally wrong - should be of the same width as in portrait (see Gogole apps) - I know, official Material design guidelines are kinda wrong in this regard.

This causes that drawer's "acount background image" is extremely huge (it should be of the same size as in portrait, because drawer should be the same wide as well).
Moreover, in landscape, account info (text) has wrong padding and accounts photos are completely displaced - aligned to the very top of the drawer.
screenshot_2014-12-20-22-49-09
The next common error for toolbar impl. is wrong text size and alignment of toolbar title in landscape.
It's too small and incorrectly aligned according to toolbar icons.
screenshot_2014-12-20-22-49-15

Toolbar+Drawer under statusbar on pre-Android L devices

However official Material design guidelines specify:
"The nav drawer spans the full height of the screen and the drawer is below the status bar."
there is a general rule appearing in all Google apps as well as in all apps updated to Material Design specs, that there is nothing under statusbar in pre-Android L versions.

This behaviour is very specific for Android L that in many cases it doesn't even look good on KitKat for example. Even fake statusbar gradient doesn't look good on this devices compared to Anroid L, which uses colorPrimaryDark for this purpose (statusbar). Btw, you should also use colorPrimaryDark from styles, not calculate it. colorPrimaryDark is supported by appCompat as well.
screenshot_2014-12-20-22-31-51
Please, at least, add an option to not put it under statusbar for pre-Android L devices.

Drawer items coloring

As per Material Design guidelines (and also in Google apps like GMail for a reference)
http://www.google.com/design/spec/patterns/navigation-drawer.html
ordinary drawer item icons (and "notifications") should be of one specific color in non selected state and that is 54% #000000, not black, nor custom colored. However text in some apps appears to be black, as per spec (guidelines) it should be 87% #000000.

When selected, icon and text in such ordinary item should become 100% black or of a custom color for a better contrast (SectionColor now in your case) and item should have a gray BG, as it already has.
See selection state in specs:
http://www.google.com/design/spec/patterns/navigation-drawer.html
How "notifications" should be colored in selected state isn't specified, but judging from GMail app, they still stay gray (no matter section has a custom color or not).

In some rare cases, coloring an icon has it's meaning (check GMail labels), but this icons shouldn't be the ones for a primary navigation purposes. BUT, text & notification colors should remain not changed in this case.

I advice to set & kinda enforce this default colors, make section color -> section icon color and add section selected color as a highlight color, if user would like to override default (and of course handle open/close re-coloring cases).

Lastly, custom coloring of section items in selected state (usually the same custom color for all items) doesn't have to affect fragment's toolbar color (by default it doesn't). It's nice feature, but should be optional for a better flexibility.

PS: drawer items (sections in this lib case) default background color shouln't be white, but #fafafa.

API level 7 compatibility

Thanks for the fantastic work so far. This library is very helpful.

I wonder if it would be possible to add backward compatibility for API level 7. As far as I have seen there are only few methods (e.g. setColorFilter()) and classes (e.g. android.app.Fragment) that are not available in API level 7.

Maybe a check against android.os.Build.VERSION counld do the trick?

Support Multiple Profiles

I think it would be a great addition to this library to support multiple profiles and switching profiles like in the Gmail app.
image

Touch Bug

there is a bug in the drawer
when i touch a section in nav drawer (not just touch but touch and swipe) it acts like it touched
and it seems to be there is more than one section opened

sorry form my bad english

Nullpointer Exception

Hi, I followed your example but I keep getting a NullPointer exception.

 Caused by: java.lang.NullPointerException
        at it.neokree.materialnavigationdrawer.MaterialNavigationDrawer.onCreate(MaterialNavigationDrawer.java:132)

This happens both, in my app and in your example app as well running on Android 4.1.1.

No way to create an almost blank "account"

For example, if you want the "account" bar to show the text "Sign up now", you just use a background and a title (no need to use a photo and a secondary text). But it's apparently impossible to do that with the available methods.

back key press

why it stuck on back press? and when I add super.onBackPressed(); it throws indexoutofbounds exception!

Learning pattern

There is a learning pattern associated with the nav drawer nature, as it is something people don't see (and some don't know it's there) until it's open. Basically what Google recommends is to open the nav drawer when starting your app everytime until user himself / herself firstly tap / swipe to open the drawer = they finally got it how it works and that it's there. It seems like pretty obvious to us, but there are some users that must be taught to do that (unfortunatelly).

If you generate a new project in Android Studio with a drawer pattern, it is already implemented there, so check it out - just one SharedPref variable, that's it ;)

No example available

I know you can download the example.apk but it would be really good to provide the source code of the example application. Doing so, we'll be able to check how to implement the library even better.

Actionbar title returns back to original title after closing menu

In certain scenarios you want an activity to change the title of the actionbar dynamically (not only at the start). But after returning back from the navigation menu it overrides whatever title you set earlier with the original title defined in newSection("Title",new WhateverFragment())

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.