Material design template

This post will help you install my Material Navigation Drawer template on Android Studio. This will help you create applications using material design faster than any other template.


 First download the latest version of the template on my github:


https://github.com/kanytu/Android-studio-material-template

  • Next copy the folder that's inside the root of the zip file, named `MaterialNavigationDrawerActivity`, to the directory located in :
`{Android Studio location}\plugins\android\lib\templates\activities`

Your directory should now look like this:



  • Now restart your Android Studio and click on
`File > New > New Project...`


Change the name of your application. Click next and set your minimum SDK. This library will only work for API level greater or equal than 7.

  • Select Material Drawer Activity


  • Now change the parameters according to your needs.

On Navigation Style there are 3 different styles:



Drawer bellow toolbar with a darken effect on the toolbar.

Drawer bellow toolbar

Drawer on top of toolbar. Uses ScrimInsetsFrameLayout if API>19


And finally on Drawer Style there are 2 types:


Simple drawer with just a RecyclerView

Google material navigation drawer. Methods like setUserData will be available


Once you click `Finish` Android Studio will start building the project. After all the tasks are finished you can run your project and see your new application.

You can start working from here. Here are some TODO guide lines to help you:

Change NavigationDrawerFragment.getMenu() method in order to add, remove or change the contents of the menu:
public List getMenu() {
        List items = new ArrayList();
        items.add(new NavigationItem(getString(R.string.search), getResources().getDrawable(R.drawable.ic_action_search)));
        items.add(new NavigationItem(getString(R.string.stats), getResources().getDrawable(R.drawable.ic_action_trending_up)));
        items.add(new NavigationItem(getString(R.string.myaccount), getResources().getDrawable(R.drawable.ic_action_account_box)));
        items.add(new NavigationItem(getString(R.string.settings), getResources().getDrawable(R.drawable.ic_action_settings)));
        return items;
    }



Change colors.xml to change your theme colors:
    <color name="myPrimaryColor">#00BCD4</color>
    <color name="myPrimaryDarkColor">#0097A7</color>
    <color name="myAccentColor">#CDDC39</color>



Change onNavigationDrawerItemSelected to change your menu behavior:
    @Override
    public void onNavigationDrawerItemSelected(int position) {
        Fragment fragment;
        switch (position) {
            case 0: //search//todo
                break;
            case 1: //stats
                fragment = getFragmentManager().findFragmentByTag(StatsFragment.TAG);
                if (fragment == null) {
                    fragment = new StatsFragment();
                }
                getFragmentManager().beginTransaction().replace(R.id.container, fragment, StatsFragment.TAG).commit();
                break;
            case 2: //my account //todo
                break;
            case 3: //settings //todo
                break;
        }
    }

Add items to main.xml to create a custom menu:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto">
    <item
        android:id="@+id/action_search"
        android:title="@string/action_search"
        app:showAsAction="always"
        android:icon="@drawable/ic_action_search_white"/>
    <item
        android:id="@+id/action_filter"
        android:title="@string/action_filter"
        app:showAsAction="ifRoom"
        android:icon="@drawable/ic_action_filter_white"/>
</menu>



Keep adapting the code to your needs and happy programming :)

Example program code can be found here: https://github.com/kanytu/template_example

Note: The template might change once in a while. Make sure to check my github to keep your template up-to-date.

Note 2: Android Studio will remove the template on each update. You need to install it after each update.

Unknown

Related Posts

168 comments

  1. Hi, thanks for the post.
    I want that when I press on "Item 2", it return me the "Fragment 2".
    How I add this? Where? Thanks

    ReplyDelete
    Replies
    1. Just use onNavigationDrawerItemSelected to change between Fragment 2 or whatever fragment you want,

      Delete
    2. Sorry but in which class?

      Delete
  2. How do I start a new activity after pressing on a item on the menu?

    ReplyDelete
    Replies
    1. This question is not related with the template. I suggest you look for help in StackOverflow. Ask how to start an Activity by clicking on a menu item.

      Delete
  3. Awesome work!

    Will sure try it!

    ReplyDelete
  4. Olá, o meu nome é César Oliveira, sou de Portugal também e também sou programador Android.
    Achei muito interessente o seu template.
    Vou fazer uns testes com ele e depois digo alguma coisa

    Parabéns

    ReplyDelete
    Replies
    1. Olá,
      O template é de facto muito bom.

      Já até lancei uma app na Play store com ele

      Mas em outro projecto estou com problemas. Adicionei em apenas uma janela do Navigation Drawer ums Tabs.

      Só que agora ao rodar a tela volta para a 1º opção do Navigation Drawer

      Como eu posso resolver esse problema

      Se estou na terceira opção e roda a tela deve continuar na 3 opção do Navigation Drawer

      Muito Obrigado
      César Oliveira

      Delete
    2. Oi César. O template não implementa toda a logica de saveInstance sozinho. Terás que aplicar essa logica por ti. Poderás usar os eventos onSaveInstanceState no fragmento para guardar a posição atual e aplicar a logica no onCreate usando o mesmo bundle

      Delete
  5. I have created a simple project using the latest version for this template and nothing it's displayed in design view though everything looks fine on text view and works like a charm on my phone. But, as I sayd a message appears in design view, "Rendering problems". Do you have a quick fix for this? The project was created in Android Studio, Windows 8 x64.

    ReplyDelete
    Replies
    1. That's a problem with RecyclerView it self. You can't render it. https://code.google.com/p/android/issues/detail?id=72117

      Delete
    2. It's seems that choosing the API 21 for Android version in AndroidStudio preview can be a temporary solution. In my case works. Thank you for great work.

      Delete
  6. Hello there. There is a little problem that i have noticed. The drawer overlaps a little into the app bar when you switch the phone to landscape mode. Aside that this template rocks!

    I would also like to know how to use xml array with NavigationDrawerFragment.getMenu() method

    Thanks in advance

    ReplyDelete
  7. Hi, I've been using this template in my app I'm creating and I'm a huge fan but I'm still trying to look for where your text is initialised to white in everything in the app theme? I know it's for the white of the of the text in the action bar but need to see the rest of my content elsewhere

    Thanks for the template, been following your repos and they've been a huge help :)

    ReplyDelete
    Replies
    1. You're right friend. Take a look at this issue about that: https://github.com/kanytu/Android-studio-material-template/issues/8

      Delete
    2. Thanks so much :) It works now. It had all my edit text hints initialised to white now I can see them. I was doing a work around initially setting a default to text views in the styles.xml to black but this was quicker. Thanks again :D

      Delete
  8. How can I add a divider to the navigation drawer?

    ReplyDelete
    Replies
    1. The same way you add a divider to a RecyclerView. You can start by searching on Google :)

      Delete
  9. Sorry for bother you again, but maybe you or another users faced same challenges as myself. Is there any possibility to slide the entire content to the right when slider is open? And second thing, I tested the app on different devices running Android from 4.1.2 to 5.1 and sometimes the click on recycle view item doesn't call the onNavigationDrawerItemSelected method. Do anyone have a fix for this?

    ReplyDelete
    Replies
    1. Hi again friend. The last issue you reported was already fixed on v1.1 as you can see on the github :) As for the "entire content" I don't think I understand what you're trying to say. You want navigation drawer to fit the whole screen? If so you will have to change the width of navigation fragment on real time and change it to the width of your screen. If you don't know it come by my github and post an issue or ask it on StackOverflow. I'm sure you'll get a fast reply :)

      Delete
    2. Thank you for your quick response and for pointing the fact that new version is available. It works like a charm.

      Delete
  10. Is there anyway to set the title of the navigation drawer for each fragment selected?

    ReplyDelete
    Replies
    1. Yes there is. Just call ActionBarActivity.getSupportActionBar().setTitle. You can call it on your MainActivity in onNavigationDrawerItemSelected.

      Delete
  11. Hello, this is really helping.
    Question, I used simple drawer below toolbar but the icons (in this term the check marks) won't appear in the drawer when I tested in my phone (Android Studio detects it though). Any solution?
    Also, how to create different drawers for different users (logged in, not logged in)? I tried using boolean isLogged and selecting items for the drawer regarding the isLogged. It can create drawer with different contents, but I have no idea how to rebuild the drawer when I change the isLogged variable.

    ReplyDelete
    Replies
    1. As for the icons not appearing I never seen that problem. I suggest you restart your Android Studio. Refreshing the contents of NavigationDrawer would be a bit more trickier. If you have the opportunity, come by my GitHub page and add an issue on the repository of this template. I will guide you there :)

      Delete
  12. Hello! The icons are really not appearing on v1.2. That is due to the fact that method onBindViewHolder (NavigationDrawerAdapter) isn't calling the drawables (it was on v1.1). Corrected that at my end and it's ok now.

    ReplyDelete
    Replies
    1. Ups :\ My bad. That should be fixed now

      Delete
  13. Hi, I've downloaded the template and successfully created a new project with it, my question is:
    Is it possible to hide the action bar? I mean: I only want to show the toggle menu button (no action bars, no settings button...), and when user clicks it, the drawer opens (in my case I'm using the full drawer, from bottom to top)
    I've tryied "mToolbar.setBackgroundColor(getResources().getColor(R.color.transparent));" but this hides the menu button too... *

    ReplyDelete
    Replies
    1. I used mToolbar.setBackgroundColor(getResources().getColor(android.R.color.transparent)); and getSupportActionBar().setTitle(""); on the main activity and it worked. If you keep having problems post an issue on my github. Remember that the drawer icons are white. So if you have a white background it's obvious that you won't see it.

      Delete
  14. Thanks, I'm a genius, I forgot that icons were white. It's possible to do something like the template but without actionBar? Simply creating a button in main screen? That's what I need and I don't find the solution...

    ReplyDelete
    Replies
    1. Yes it is. Simple remove the toolbar include from your xml and from the MainActivity itself (remove all SupportActionBar suff). Next to open the drawer just call mNavigationDrawerFragment.openDrawer() or mNavigationDrawerFragment.closeDrawer() to close. By the way, you can change the color of the drawer icon by changing the value in your styles.xml (inside DrawerArrowStyle change the color attribute)

      Delete
  15. I use v1.3 for the first time and I get this error: "Error:(51, 61) error: cannot find symbol variable row_selector" in the NavigationDrawerAdapter.java. Any ideas?

    ReplyDelete
    Replies
    1. I don't see how can you get that error. I will have to investigate it. However, you can create a file called row_selector.xml inside your drawables folder and change it's contents to: https://github.com/kanytu/Android-studio-material-template/blob/master/MaterialNavigationDrawerActivity/root/res/drawable/row_selector.xml

      Delete
  16. Hey Perdo,

    I used your Navigation Drawer version 1.3. It is excellent and easy to use.

    However I found the width of the navigation drawer slightly more than that in Google applications. Also there is no ripple effect when an item is selected in the navigation drawer.
    Would be great if you could fix those issues.

    ReplyDelete
    Replies
    1. Hi. You can change the width of your navigation by changing the file "dimens.xml" and change the value "navigation_drawer_width" to whatever you want. As for the ripple effect you're right. I will have to study a bit more about it so it supports that effect. Thanks for pointing that out.

      Delete
    2. Hey Pedro, thanks for the reply.

      I researched a bit and I could figure out how to implement the ripple effect.

      In drawer_row.xml,
      Remove these four options,

      android:layout_marginLeft="16dp"
      android:layout_marginStart="16dp"
      android:layout_marginRight="16dp"
      android:layout_marginEnd="16dp"

      And just add,

      android:background="?android:attr/selectableItemBackground"

      The ripple effect will be implemented.

      Delete
  17. Also, if I use gray icons for the items in the nav drawer. How do I change the icon to a black version on the item being pressed?

    ReplyDelete
    Replies
    1. That can be easily achieved by changing the NavigationItem and adding a new drawable. Next change onBindViewHolder on the NavigationAdapter and perform checks there to see if the item is selected or not and change the compound drawable accordingly.

      Delete
    2. Please help me implement this. I followed your advice but only the first time the standard icon is being replaced by the selected icon. If keep selecting menu items, eventually they all are replaced by the selected icon. For example, the first time the application runs and I open the navigation drawer, the standard icon of the first menu item is replaced by the selected icon (which is fine). But if I select the second one, the first one retains the selected icon when it should have gone back to standard icon. Please help me do this.

      Delete
  18. Hi Pedro,

    Thanks for this...its brilliant :D

    One question, I have done my switch case like this:

    @Override
    public void onNavigationDrawerItemSelected(int position) {
    Fragment fragment;
    FragmentManager fragmentManager = getFragmentManager();
    switch (position) {
    case 0:
    fragment = new Fragment1();
    break;
    case 1: //stats
    fragment = new Fragment1();
    break;
    case 2:
    fragment = new Fragment1();
    break;
    case 3:
    fragment = new Fragment1();
    break;
    }
    fragmentManager.beginTransaction()
    .replace(R.id.container, fragment)
    .commit();
    }

    Will this work? Thanks in advance :)

    ReplyDelete
    Replies
    1. As far as I can see yes it will work. But it will show always the same fragment for the 4 items on the navigation drawer.

      Delete
    2. Yes i know what you mean, I was only using that as an example thats all.

      Delete
    3. Hi, I'm using the same, but other way to call activities ??
      try the Intent option does not work with the template.
      -------------------------------------------------------------------------------------------------------------------
      Hola yo estoy usando lo mismo, pero hay otra forma de llamar actividades??
      intente con la opción Intent, pero no funciona con el template.

      Delete
  19. Good evening I'm beginning to learn android, this appearing the following error:

    android.support.v7.widget.recyclerview

    can you help me?

    thank you

    ReplyDelete
    Replies
    1. That's not an error. That's most likely a warning that the program couldn't render RecyclerView. Your program will run anyway :)

      Delete
  20. Hi Pedro,
    Thanks for the awesome work and I need one more help!

    I want to generate my ic_laucher logo with the app title in toolbar_actionbar.
    Is it possible?

    ReplyDelete
    Replies
    1. Hi. As far as I know you could use getSupportActionBar().setIcon() to display your ic_launcher logo :)

      Delete
  21. Hi Pedro,
    Nice work!

    I have a doubt.
    How to add SubMenu in Navigation Drawer?
    Item1
    ...SubItem1
    ...SubItem2
    ...SubItem3
    Item2
    ...SubItem1
    ...SubItem2
    Item3
    ...SubItem1
    ...SubItem2
    ...SubItem3
    ...SubItem4

    ReplyDelete
    Replies
    1. Hi. For that you will need to use a ExpandableRecyclerView instead of the normal RecyclerView included on the project. There are some implementations out there but you could start from here : http://stackoverflow.com/questions/26419161/expandable-list-with-recyclerview

      Delete
  22. Hey Pedro,

    An update to the support library was launched. Will it change your library in anyway?
    http://android-developers.blogspot.in/2015/04/android-support-library-221.html

    ReplyDelete
    Replies
    1. Yes it will change a couple of things. Nothing too important since deprecation usage is still allowed.

      Delete
  23. Hello Developer
    I am not able to get the action bar in android < 5.0. But in 5.0 everything is perfect. How do I make the action bar visible?
    Android 4.4: http://pasteboard.co/2Neie0Pv.png
    Android 5.0: http://pasteboard.co/2Nel9u2v.png

    ReplyDelete
    Replies
    1. Hi. I think that has to do with the toolbar size you chose. Try creating a new xml file for pre lollipop for your activity. If you're having troubles with it come by my github

      Delete
    2. Can you please guide me what to do after creating xml for pre lolipop?

      Delete
  24. Hello Pedro.

    Just drop by to say a big thank you.

    Used your template as base in order to update an Xposed Module. Besides your template, I've managed to add custom separators on the RecyclerView as well as ripple effect, for any android running on ICS+, as background selection. Had to "disable" the "user has learned drawer existence" feature because it was interfering with the module ability to apply it's modifications on the fly.

    I really must thank you. Could not get there all alone, since I'm still learning.

    Case you're interested (you and anyone reading this) :

    https://github.com/ElTifo/Xposed-SmoothProgressBar

    ReplyDelete
  25. When I start a new activity with MainActivity as a parent - the notification/status bar doesn't show.
    I've tried this:
    getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    But no luck.

    Is there anything that I need to put in my layout to show the notification/statusbar?

    ReplyDelete
  26. Hi, thanks for template. Is there any easy way to change the drawer style?

    ReplyDelete
    Replies
    1. Yes there is. You can change fragment_navigation_drawer.xml to whatever you like

      Delete
  27. Hi, i am howard. May i know how to do multiple activities in this navigation drawer template.
    Because now when i add new activity. It will pop out another page and in the same page. i am the beginner in developing android app

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
    2. Hi Howard. This is best used with fragments and not activities.

      Delete
    3. hi, where should i create the fragment?

      Delete
    4. It's better to search on Google because this is not an easy topic to explain in the comment section.

      Delete
  28. You rock! Was just reading about material design and i said to myself, somebody probably made a template for what i need and bam! GG! :)

    ReplyDelete
  29. p.s. Glad you kept it nice and clean. Perfect place to start building an app.

    ReplyDelete
  30. Can I bother you with a question related to best design practices in a slightly weird design? I using your Material Design Template and I need an advice regarding the the following fact: I have some menu options(from left menu) each one with related fragment and 2 of them have same header with tab navigation(option 1 for 1st fragment, option 2 for 2nd fragment). I need both menu and tab navigation(silly design maybe, not mine). What is the best method to change the current selected item and replace current fragment with another? Ohert fragments have different headers(toolbar) and for the MainActivity I used
    mToolbar.setBackgroundColor(Color.TRANSPARENT);
    getSupportActionBar().setTitle("");
    to hide the action bar. Thanks in advance!

    ReplyDelete
    Replies
    1. You can call MainActivity.onNavigationDrawerItemSelected with no problem. If you have a correct logic on that method (as you should) it will replace the fragments with no problem

      Delete
    2. Thank you for response. I used your advice like this:
      MainActivity hostActivity = (MainActivity) getActivity();
      hostActivity.onNavigationDrawerItemSelected(position);
      because of non-static onNavigationDrawerItemSelected method which cannot be referenced from static context. I posted my repplay meybe someone else need it. Have a great day!

      Delete
    3. Yes. MainActivity.onNavigationDrawerItemSelected will not work ofc. That was just a way of telling which method you need to call :). Glad you figured it out by yourself. Keep up the good work :P

      Delete
  31. main activity is overlapping with other activity...
    need help
    screens here..

    https://www.dropbox.com/s/infe7blw1bm9u04/device-2015-05-07-095227.png?dl=0

    https://www.dropbox.com/s/mkqoir5mfs5q4pv/device-2015-05-07-095253.png?dl=0

    https://www.dropbox.com/s/qpywee18o57v9yz/device-2015-05-07-100601.png?dl=0

    ReplyDelete
  32. Hi Pedro. I am impressed and following recently.
    Kindly take a note that ActionBarActivity is now deprecated

    https://developer.android.com/reference/android/support/v7/app/ActionBarActivity.html

    Can you please suggest the change?

    ReplyDelete
    Replies
    1. Hi Teju. I'm aware of that but unfortunately that can't be done without compromising the template for others that haven't updated the support library yet. You can follow the discussion here: https://github.com/kanytu/Android-studio-material-template/pull/13

      Delete
  33. Hi,

    How can I install this on Intellij IDEA? The folder structure you mention on Github doesn't seem to exist (.../plugins/android/lib/templates/activities) and I can't seem to find any documentation on how to add new types of Activities.

    Thanks.

    ReplyDelete
    Replies
    1. Hi, could you check this? https://github.com/kanytu/Android-studio-material-template/issues/14 Thanks

      Delete
  34. Hi, pedro thanks for your work for this theme, my problem is, i have other Activity, but i dont need the Drawer ,i need change de status bar color, before I chance status bar color in Main Activity and works fine, but in other Activity, how can i change the color? thanks

    ReplyDelete
    Replies
    1. Hi. Both activities have to have the same theme. Check the manifest file to see if their theme is the same

      Delete
  35. Hey Pedro,
    Yours is the best template I had ever worked.It would be great if you could help me in adding Expandable ListView to one the items in the menu of NavigationDrawer.

    ReplyDelete
    Replies
    1. Hi. I would help you no problem. However you didn't gave me much to work on. Come by my github page or send me a personal email and I will get back at you once I have the time

      Delete
  36. Hey Pedro,
    Thanks for the amazing template.It would be great if you could help in adding ExpandableListView to one of the items in the menu of NavigationDrawer.

    ReplyDelete
  37. This comment has been removed by a blog administrator.

    ReplyDelete
  38. Awesome work Pedro! Quick question, how do I switch between fragments? Also these fragments that I added, do I have to add them to main.xml. Thanks again for this awesome template.

    ReplyDelete
    Replies
    1. You don't have to change your xml in order to add/remove or replace fragments. You can check my example project at https://github.com/kanytu/template_example for more on how to change between fragments. Hint: Check onNavigationDrawerItemSelected

      Delete
  39. Pedro Awesome work!
    Quick question, I've added seven more fragments, how do I switch between these, I tried to use the example you have but that displays only the first fragment created. Thanks again.

    ReplyDelete
    Replies
    1. To change between fragments you will have to work with FragmentTransactions. Check the replace and add method them. Good luck

      Delete
  40. Hi, I'm wondering if there is an easy way to scale the TextView drawables, thank you!

    ReplyDelete
    Replies
    1. You should look for another place to ask things like that have nothing to do with the template itself. Like stackoverflow.com for example :)

      Delete
  41. Excellent Class. Two feedback for your considerations:

    1) Add int ID in NavigationItem which is easier to handle in callback than the position
    2) Add getMenu method in NavigationDrawerCallbacks so that NavigationDrawerFragment is independent of application specific code. MainActivity can then manage the menu.

    ReplyDelete
    Replies
    1. Good suggestions. I will take that in consideration on the next versions. Thanks for your feedback :)

      Delete
  42. Hi, Thanks for your great work!
    I've got two questions:
    1. How can I disable the DrawerIcon rotation? As my Drawer is above ActionBar it doesn't make sense. Setting false does not work for me. Maybe disabling this in the template for full-height Drawer is also an option?
    2. I am looking for a way to have the Drawer really full-height I already made the NavigationBar transparent, but I didn't find a way to have the NavigationDrawer above it.
    Already tried to to add android:fitsSystemWindows="true" to ScrimInsetsFrameLayout, but nothing changed.

    ReplyDelete
    Replies
    1. Hi. 1. I think you can achieve that by setting a custom drawer icon to your toolbar.
      2. Check android:windowTranslucentNavigation on your theme. There's also a bunch of tutorials on the internet about overlapping the navigation bar. Good luck

      Delete
  43. Hi this is reallly great work. I am having the same issues as adhik joshi - the fragments start overlapping with each other when the back button is pressed. I am using addtoBackStack(null). What would be the reason for this happening? Thanks.

    ReplyDelete
  44. Olá Pedro! Can you please help me with an advice? For one of navigation items I have a text field that display the number of news. I changed the design for drawer row and the code in adapter(onBindViewHolder) in accordance, but the only time I can set the text for that field is on getMenu() method in NavigationDrawerFragment -> onCreate. Is there any method so can I easily change the text in that field? I need to access that field from MainActivity(host activity)

    ReplyDelete
    Replies
    1. Hey :) Let me give you some tips. If you still can't implement this place an issue on my github and I will help you there ^^. Start by adding a field on NavigationItem which is the number of news to display. Next on onBindViewHolder set the text of the news according to the value on NavigationItem. Next you just have to create a method the drawer fragment to refresh the adapter (notififyDatasetChanged or similar). Hope it helps

      Delete
  45. What I need to do to add a divider in a unique position? I don't need it between all items

    Entry 1
    Entry 2
    Entry 3
    ----------------------
    Settings

    ReplyDelete
    Replies
    1. You will need to change the onBindViewHolder of the adapter to inflate a new view depending on the position. The new view should be a view with your divider. More info on multiple view types: http://stackoverflow.com/a/26245463/3410697

      Delete
  46. Hi! Is it possible to not preselect an item from menu? I want to open a "custom fragment" when I open the app, that fragment it's not in the side menu.
    Now, when I start the app, the first option of the menu becomes auto selected.
    Thanks

    ReplyDelete
    Replies
    1. Yes it is. Just remove the selectItem(mCurrentSelectedPosition); line on onCreateView's method of NavigationDrawerFragment

      Delete
  47. Exellent work! Grab it as must have tool!
    Please, tell how to turn off humburger-to-arrow transition in toolbar, need only permanent humburger?

    ReplyDelete
    Replies
    1. I think you can do that by overriding the icon to a custom drawer icon.

      Delete
  48. HI!
    My Android Studio sais:
    The class com.android.support.v7.RecyclerView could not be found

    Can you help me to fix this problem please?

    ReplyDelete
    Replies
    1. Make sure you're installed the support library. You can check if you have installed by going to this folder /extras/android/support/v7/recyclerview/

      Delete
    2. Hello.

      I found the answer here:

      http://stackoverflow.com/questions/29005644/rendering-problems-java-lang-nullpointerexception-at-android-support-v7-widget

      I used the first answer. Basically, you have to remove android:scrollbars="vertical" from fragment_notification_drawer.xml. There seems to be some known bug involving RecyclerView which may be unrelated.

      Delete
    3. Quick question: I am a development newbie and was wondering whether it is acceptable to use this template for commercial purposes? It has been remarkably hard to find a tutorial or template for a navigation drawer without an action bar but with an app/tool bar. Even the stock android "Navigation Drawer Activity" template makes use of an action bar regardless of the fact that the action bar has been deprecated, which doesn't make sense. So thank you for your work, regardless of whether I am allowed to use it.

      Delete
    4. Quick update: after removing android:scrollbars="vertical" and reading somebody's complaint that removing something is not a solution, I decided to put android:scrollbars="vertical" back where it originally was and it WORKED. There were no more rendering issues. So by undoing something and then redoing it the rendering issues disappeared... which is quite weird and glitchy.

      Delete
    5. It's located in Sdk/extras/android/m2repository/com/android/support/v7/recyclerview-v7

      What sould I do?

      Delete
  49. Hi Pedro,

    Thanks a lot for creating this template. I'm currently developing my first Android app and helped me a lot to get started.

    Is this template only intended to be used with single-activity apps? I understand that the concept is to change the current fragment in the container after the user clicked a menu item.

    I've tried to use the menu item in a second activity, basically by moving most of the related code to a base class. But somehow it performs not optimal, for example the animation to collapse the menu starts while at the same time the next activity is started.

    Do you only use single-activity apps with this kind of menu or how do you manage things like this? Thanks a lot!

    ReplyDelete
    Replies
    1. Hey Arne. You can use the template the way you want. However, the current pattern for Navigation Drawer apps is to have an activity that shows the navigation menu and it's items are displayed on it with a multi fragment architecture. Other options on the selected fragment (display more info, add info etc...) should be taken on another activity.

      Delete
    2. Hi Pedro,

      Thanks for your answer! So I would have the "home" activity with the dynamic fragment part and the navigation drawer. For any sub-activity, like edit the details of a data item or the settings screen, I would create a new activity without the navigation but only a back button.Correct? Thanks!

      Delete
    3. Yes you're correct. However if you're displaying the settings page on your drawer it should be better to have it as a fragment too. However if it is opened by another action than the navigation drawer than it's okay to show it as an activity. Good luck :)

      Delete
  50. This comment has been removed by a blog administrator.

    ReplyDelete
  51. Hi pedro,thank you for the template, everything is working perfectly. i have 2 problems and i have been trying to fix it.
    1: where do i set the title of for each fragments?
    2: Am trying to change the profile picture to a dynamic image(that fetches from a url). Have changed the name and email, but each time i chanange the (R.drawable.Avatar) to an imageview[findviewbyid(R.id.image)] the app crashes. Please kindly help with this

    ReplyDelete
    Replies
    1. Hey.
      1. On your fragment's onActivityCreated method just call getSupportActionBar().setTitle("My title");
      2. Without the crash trace this will be hard to figure out. Create an issue on my Github if you still have troubles setting the image

      Delete
  52. Thank you very much oliveira, the image loads after running the app the second time. The title has been changed. thanks alot

    ReplyDelete
  53. Quick question: I am a development newbie.
    as I can return to navigation * * drawer by pressing the back button without going through the fragment ?

    ReplyDelete
    Replies
    1. You just have to code onBackPressed by yourself. If you want to open the drawer just call mNavigationDrawerFragment.openDrawer() and do not call popBackStack or super.onBackPressed and you should be fine :)

      Delete
  54. Thank you Bro!!!
    my search for material navigation drawer ends here..!!
    Great Work:)

    ReplyDelete
  55. Awesome tutorial.keep up the good work

    ReplyDelete
  56. Hi Pedro. Thanks again for the nice template. I am having a problem that I hope you might be able to assist. I am customizing the header section of the navigation drawer and replacing it with actual ,profile information using Google Plus API.So far I have succeeded in displaying username and email but I have trouble retrieving and displaying user profile picture. Kindly assist. This is the link to my github project https://github.com/kandieamdany/NewMaterialDesign

    ReplyDelete
  57. Hello.
    Thank you for the impressive work.

    I have a small problem with the model Google material navigation drawer.
    I have 25 items in the list (getMenu), when you scroll down the selects its several different items list.

    Thank you in advance :)

    ReplyDelete
    Replies
    1. Hey friend. This was fixed here: https://github.com/kanytu/Android-studio-material-template/commit/5e82be763c135389fe420c357546d69123971002

      Delete
  58. Does anyone have this problem? Link to video: http://apollo.eed.usv.ro/~pahomi_a/for_pedro_o.html . More info can be found here, also if anyone know how this can be fixed, please leave a comment here: https://github.com/kanytu/Android-studio-material-template/issues/28.

    ReplyDelete
  59. Hi Pedro Oliveira,

    Thank you very much for this post..

    I just want to ask how to display page after i click navigation?
    example: after i click about nav, it will go to about page..

    Im new to android i hope someone can help me..
    anyone can provide a simple code how to do it with xml and java..

    sorry for my bad english.

    Thanks,
    Joe

    ReplyDelete
  60. git@github.com:jgilfelt/androidicons-adt-template.git gives me an error when I try to clone in Android Studio.

    ReplyDelete
  61. Finally found a good template to start with.
    Good job!

    ReplyDelete
  62. Hallo Pedro!
    nice template.
    only one quation.
    how to add sliding tabs?

    ReplyDelete
  63. Got these errors---->

    Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'.
    Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Colored'.

    ReplyDelete
  64. Olá, gostei muito da iniciativa, estou implementando em um projeto, gostaria de saber como posso trabalhar o tamanho dos ícones e a margem do texto em relação ao ícone? Obrigado!

    ReplyDelete
    Replies
    1. Oi, é tudo facilmente editavel. Basta alterar o xml "drawer_row" e pode alterar margens no texto. Quanto ao tamanho do texto eu estou usando compoundDrawables que apenas suportam padding. Mas poderá alterar o conteudo do drawer_row ao seu gosto

      Delete
  65. Great Job. I have also posted some material design post in www.viralandroid.com

    ReplyDelete
  66. Am I missing something? In the latest Android Studio 1.4 beta I get no files, just folders and build files

    ReplyDelete
    Replies
    1. yes friend. You are probably missing something. Check the Android directory. Example of the file path: C:\Android Studio\plugins\android\lib\templates

      Delete
  67. i have a problem with the preferences activity. I have made a new PreferencesActivity with preferences.xml and start a new activity from menu but i it dont have an actionbar :(

    ReplyDelete
    Replies
    1. Make sure you add the toolbar to your xml.

      Delete
  68. how can I show the drawer in the right side
    I've tried the layout_gravity and it did not work
    android version (1.4)

    ReplyDelete
    Replies
    1. Hey. This might help you friend https://github.com/kanytu/android-material-drawer-template/issues/22

      Delete
  69. pedro i have question T how can i make the drawer to open from right to left ?

    ReplyDelete
    Replies
    1. Hey. You can check here: https://github.com/kanytu/android-material-drawer-template/issues/22

      Delete
  70. Just wanted to thank you for making this.. did better than Google lol...

    ReplyDelete
  71. Hello, thank you very much for your template . Is it possible to present the menu as follows:
    Title :
    Item 1
    Item 2

    Title :
    Item 3
    Item 4

    Thx in advance

    ReplyDelete
  72. Hello Is it possible to use in eclipse ?

    ReplyDelete
    Replies
    1. I think so. I haven't tested it yet. But you can try placing the template in "SDK_FOLDER/extras/templates/activities" and try opening it in eclipse

      Delete
  73. Hello,
    I use your tipps.My program run a device (Xperia Z1 Compact), but it's not working on (normal) Xperia Z. What can I do?

    ReplyDelete
  74. Pedro, sou do Brasil e gostei muito do template. Mas tenho uma duvida, como faço pra botar o Drawer bellow toolbar?
    Grato!

    ReplyDelete
  75. Where do I find this "{Android Studio location}\plugins\android\lib\templates\activities," folder, I've been looking for it for an hour. On Mac.

    ReplyDelete
    Replies
    1. Hey buddy, Just open your Applications. Then search Android Studio, right click on the icon and select "Show package contents". You should be able to go on from that

      Delete
  76. Hi Pedro, excellent template dude!! There is just a little problem (bug). When using more then 14 NavigationItems in the List, there are two selected items and over 28 there is 3 selected and so forth. There should be just one selected at a time. How can we fix this behaviour?

    ReplyDelete
    Replies
    1. Hey friend. This was fixed here: https://github.com/kanytu/Android-studio-material-template/commit/5e82be763c135389fe420c357546d69123971002

      Delete
  77. Hey Pedro,

    I would like to ask you if I could use the picture that you put in your documentations. I think of this picture: https://github.com/kanytu/Android-studio-material-template/blob/master/MaterialNavigationDrawerActivity/root/res/drawable/wallpaper.png

    I'm making an app but I don't really know the license right and because of it I ask you.

    ReplyDelete
    Replies
    1. Hi friend. Feel free to use that image. As you can see here the image is free:
      https://www.google.com/search?tbs=sbi:AMhZZiuXsqQLbaZqa53EwLfCujm9LerXaJv-odyPbrZXkPYlp7rufMvCAYBLzEvFdmPpkMLaT_1bfxUuatYoRcgcP-fLsn4T-qts3h72LRHCo6dUGDINvpC9h0hgvgb-59u5I_1INoRknqIbZnsoeuwS0QxcKzHgaoJzuAkxz1CSeG_1xQVDK5uPGELVyc7t8UTYSUr8xSxobxwFLPaAQAHCAzvY6LXNu16o7z_1AfeAPP3AXCB_1UOqRLSiASzo9aK818jvmkiRtVCijR-_1LUBzK2NA3XDBwUD1T_1QG9Ovol7dCez43_1TiUYc6v2RnHtMw2VUOXM9GYxlBzCquwYr-8vfWhPs7lwcpLWMedldTBtz9zTvc6vr5ap7NFKWDU8RU_1YUcA-vk0CUY5A0BxFbHkawBqoPEx3zv8pHVcfRrUaDIOHjr5nnCOxvkHRvQTGwnIm4UrwyjsM3Tx5I2YfNKCVbxP0NHVKlP4G0EFbTCDDVFqM7Lqwuf0ByUmVLg2EqT05QcNTs9P_17SigdqZjalaWKyM8tYs1m6B71T7e52SGOZMz-XXQ090YpkHqAiDLXgWeEEo9MQ9AMNoc4jnn_1zvgc8FLImXXsKcwqSbvPkShfw8JkYThqhPqJO1pb3lwBQJDYk97dVlGXFt_1FMIW-adefoPB9h89_1OrPCnnbr3bLCThi1Uiga9fNmJ4CtjYHgL7mzG9mOGO6XnV9px2dNvZ6-6zrVhWbGenlZ0cQyPakdMAbHCzGZtPShYqno1AZO7aXtj3JfF_1jYK9n&hl=pt-PT

      Delete
  78. Really awesome blog. Your blog is really useful for me. Thanks for sharing this informative blog. Keep update your blog.

    Google App Integration Chennai

    ReplyDelete
  79. I'm impressed at your knowledge base....seems you have TREMENDOUS insight...
    I have a problem:
    1) when attempting to use API 23 or above get a error of Overlay's
    2) when attempting to step back to API22...get Error:(4) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'.
    IS there a solution?

    Thanks for taking an interest

    ReplyDelete
    Replies
    1. Hey friend :)
      Thank your for your kind words.

      Here are some information on your problems:
      1) Add the following lines your AppTheme in styles.xml

      <item name="windowNoTitle">true</item>
      <item name="windowActionBar">false</item>

      2) When you downgrade your version make sure you also downgrade your libraries. You are most likely using a support library v25 which will not work because manifests will be merged and you get values from v25 library which will not work. Also when downgrading make sure you remove the lines you added in 1)

      Have a nice day \o

      Delete
  80. Hi Pedro,
    Thanks for the great post man. Inspired a lot by your blog posts. Keep update more details about the android market. Will be waiting for the next post.

    ReplyDelete
  81. This is one of the best post I have seen recently which has a bunch of informative and useful content.

    ReplyDelete
  82. OMG! What an amazing post?? Thanks for sharing the post. I love reading your blog posts. Will I get an update on Android Rooting as well.

    ReplyDelete
  83. To be frank I have done an analysis on the data which you have mentioned in this post after that I can realize that maximum of the information are true and unique. Thanks for maintaining a blog in proper way.

    ReplyDelete
  84. Hey Pedro,
    You are rocking mann! An amazing post indeed! And I love the way you explained it. Keep going and thanks for the great post.

    ReplyDelete
  85. Great Post! Thanks for sharing the informative stuff in your blog. Keep on updating.

    ReplyDelete
  86. All posts in this blog are always contain a informative stuff. Keep on updating

    ReplyDelete
  87. Hey! Just an amazing information. Keep on Updating. You are rocking. Thanks for sharing this.

    ReplyDelete
  88. OMG! What an interesting post! Pedro you are just amazing mann! And I am becoming a great fan of your blog posts. Amazing work and thanks so much for sharing.

    ReplyDelete
  89. This blog is full of informative and useful post. Keep on updating.

    ReplyDelete