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 :
Your directory should now look like this:
- Now restart your Android Studio and click on
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:
And finally on Drawer Style there are 2 types:
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.
Rocking Work...
ReplyDeleteHi, thanks for the post.
ReplyDeleteI want that when I press on "Item 2", it return me the "Fragment 2".
How I add this? Where? Thanks
Just use onNavigationDrawerItemSelected to change between Fragment 2 or whatever fragment you want,
DeleteSorry but in which class?
DeleteOn the MainActivity.
DeleteOn the MainActivity.
DeleteHow do I start a new activity after pressing on a item on the menu?
ReplyDeleteThis 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.
DeleteAwesome work!
ReplyDeleteWill sure try it!
Olá, o meu nome é César Oliveira, sou de Portugal também e também sou programador Android.
ReplyDeleteAchei muito interessente o seu template.
Vou fazer uns testes com ele e depois digo alguma coisa
Parabéns
Olá,
DeleteO 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
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
DeleteI 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.
ReplyDeleteThat's a problem with RecyclerView it self. You can't render it. https://code.google.com/p/android/issues/detail?id=72117
DeleteIt'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.
DeleteHello 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!
ReplyDeleteI would also like to know how to use xml array with NavigationDrawerFragment.getMenu() method
Thanks in advance
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
ReplyDeleteThanks for the template, been following your repos and they've been a huge help :)
You're right friend. Take a look at this issue about that: https://github.com/kanytu/Android-studio-material-template/issues/8
DeleteThanks 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
DeleteHow can I add a divider to the navigation drawer?
ReplyDeleteThe same way you add a divider to a RecyclerView. You can start by searching on Google :)
DeleteSorry 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?
ReplyDeleteHi 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 :)
DeleteThank you for your quick response and for pointing the fact that new version is available. It works like a charm.
DeleteIs there anyway to set the title of the navigation drawer for each fragment selected?
ReplyDeleteYes there is. Just call ActionBarActivity.getSupportActionBar().setTitle. You can call it on your MainActivity in onNavigationDrawerItemSelected.
DeleteHello, this is really helping.
ReplyDeleteQuestion, 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.
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 :)
DeleteHello! 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.
ReplyDeleteUps :\ My bad. That should be fixed now
DeleteHi, I've downloaded the template and successfully created a new project with it, my question is:
ReplyDeleteIs 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... *
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.
DeleteThanks, 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...
ReplyDeleteYes 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)
DeleteThanks for your help!
ReplyDeleteI 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?
ReplyDeleteI 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
DeleteHey Perdo,
ReplyDeleteI 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.
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.
DeleteHey Pedro, thanks for the reply.
DeleteI 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.
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?
ReplyDeleteThat 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.
DeletePlease 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.
DeleteHi Pedro,
ReplyDeleteThanks 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 :)
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.
DeleteYes i know what you mean, I was only using that as an example thats all.
DeleteHi, I'm using the same, but other way to call activities ??
Deletetry 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.
Good evening I'm beginning to learn android, this appearing the following error:
ReplyDeleteandroid.support.v7.widget.recyclerview
can you help me?
thank you
That's not an error. That's most likely a warning that the program couldn't render RecyclerView. Your program will run anyway :)
DeleteHi Pedro,
ReplyDeleteThanks 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?
Hi. As far as I know you could use getSupportActionBar().setIcon() to display your ic_launcher logo :)
DeleteHi Pedro,
ReplyDeleteNice work!
I have a doubt.
How to add SubMenu in Navigation Drawer?
Item1
...SubItem1
...SubItem2
...SubItem3
Item2
...SubItem1
...SubItem2
Item3
...SubItem1
...SubItem2
...SubItem3
...SubItem4
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
DeleteHey Pedro,
ReplyDeleteAn 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
Yes it will change a couple of things. Nothing too important since deprecation usage is still allowed.
DeleteHello Developer
ReplyDeleteI 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
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
DeleteCan you please guide me what to do after creating xml for pre lolipop?
DeleteHello Pedro.
ReplyDeleteJust 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
When I start a new activity with MainActivity as a parent - the notification/status bar doesn't show.
ReplyDeleteI'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?
Hi, thanks for template. Is there any easy way to change the drawer style?
ReplyDeleteYes there is. You can change fragment_navigation_drawer.xml to whatever you like
DeleteHi, i am howard. May i know how to do multiple activities in this navigation drawer template.
ReplyDeleteBecause 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
This comment has been removed by the author.
DeleteHi Howard. This is best used with fragments and not activities.
Deletehi, where should i create the fragment?
DeleteIt's better to search on Google because this is not an easy topic to explain in the comment section.
DeleteYou rock! Was just reading about material design and i said to myself, somebody probably made a template for what i need and bam! GG! :)
ReplyDeletep.s. Glad you kept it nice and clean. Perfect place to start building an app.
ReplyDeleteCan 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
ReplyDeletemToolbar.setBackgroundColor(Color.TRANSPARENT);
getSupportActionBar().setTitle("");
to hide the action bar. Thanks in advance!
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
DeleteThank you for response. I used your advice like this:
DeleteMainActivity 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!
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
Deletemain activity is overlapping with other activity...
ReplyDeleteneed 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
Hi Pedro. I am impressed and following recently.
ReplyDeleteKindly 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?
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
DeleteHi,
ReplyDeleteHow 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.
Hi, could you check this? https://github.com/kanytu/Android-studio-material-template/issues/14 Thanks
DeleteHi, 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
ReplyDeleteHi. Both activities have to have the same theme. Check the manifest file to see if their theme is the same
DeleteHey Pedro,
ReplyDeleteYours 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.
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
DeleteHey Pedro,
ReplyDeleteThanks 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.
This comment has been removed by a blog administrator.
ReplyDeleteAwesome 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.
ReplyDeleteYou 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
DeletePedro Awesome work!
ReplyDeleteQuick 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.
To change between fragments you will have to work with FragmentTransactions. Check the replace and add method them. Good luck
DeleteHi, I'm wondering if there is an easy way to scale the TextView drawables, thank you!
ReplyDeleteYou should look for another place to ask things like that have nothing to do with the template itself. Like stackoverflow.com for example :)
DeleteExcellent Class. Two feedback for your considerations:
ReplyDelete1) 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.
Good suggestions. I will take that in consideration on the next versions. Thanks for your feedback :)
DeleteHi, Thanks for your great work!
ReplyDeleteI'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.
Hi. 1. I think you can achieve that by setting a custom drawer icon to your toolbar.
Delete2. Check android:windowTranslucentNavigation on your theme. There's also a bunch of tutorials on the internet about overlapping the navigation bar. Good luck
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.
ReplyDeleteOlá 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)
ReplyDeleteHey :) 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
DeleteWhat I need to do to add a divider in a unique position? I don't need it between all items
ReplyDeleteEntry 1
Entry 2
Entry 3
----------------------
Settings
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
DeleteHi! 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.
ReplyDeleteNow, when I start the app, the first option of the menu becomes auto selected.
Thanks
Yes it is. Just remove the selectItem(mCurrentSelectedPosition); line on onCreateView's method of NavigationDrawerFragment
DeleteExellent work! Grab it as must have tool!
ReplyDeletePlease, tell how to turn off humburger-to-arrow transition in toolbar, need only permanent humburger?
I think you can do that by overriding the icon to a custom drawer icon.
DeleteHI!
ReplyDeleteMy Android Studio sais:
The class com.android.support.v7.RecyclerView could not be found
Can you help me to fix this problem please?
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/
DeleteHello.
DeleteI 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.
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.
DeleteQuick 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.
DeleteIt's located in Sdk/extras/android/m2repository/com/android/support/v7/recyclerview-v7
DeleteWhat sould I do?
Hi Pedro,
ReplyDeleteThanks 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!
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.
DeleteHi Pedro,
DeleteThanks 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!
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 :)
DeleteThis comment has been removed by a blog administrator.
ReplyDeleteHi pedro,thank you for the template, everything is working perfectly. i have 2 problems and i have been trying to fix it.
ReplyDelete1: 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
Hey.
Delete1. 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
Thank you very much oliveira, the image loads after running the app the second time. The title has been changed. thanks alot
ReplyDeleteQuick question: I am a development newbie.
ReplyDeleteas I can return to navigation * * drawer by pressing the back button without going through the fragment ?
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 :)
DeleteThank you Bro!!!
ReplyDeletemy search for material navigation drawer ends here..!!
Great Work:)
Awesome tutorial.keep up the good work
ReplyDeleteHi 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
ReplyDeleteHello.
ReplyDeleteThank 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 :)
Hey friend. This was fixed here: https://github.com/kanytu/Android-studio-material-template/commit/5e82be763c135389fe420c357546d69123971002
DeleteDoes 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.
ReplyDeleteHi Pedro Oliveira,
ReplyDeleteThank 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
git@github.com:jgilfelt/androidicons-adt-template.git gives me an error when I try to clone in Android Studio.
ReplyDeleteFinally found a good template to start with.
ReplyDeleteGood job!
Hallo Pedro!
ReplyDeletenice template.
only one quation.
how to add sliding tabs?
Got these errors---->
ReplyDeleteError:(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'.
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!
ReplyDeleteOi, é 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
DeleteGreat Job. I have also posted some material design post in www.viralandroid.com
ReplyDeleteAm I missing something? In the latest Android Studio 1.4 beta I get no files, just folders and build files
ReplyDeleteyes friend. You are probably missing something. Check the Android directory. Example of the file path: C:\Android Studio\plugins\android\lib\templates
DeleteExcellent Work...
ReplyDeletemany are now deprecated
ReplyDeletei 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 :(
ReplyDeleteMake sure you add the toolbar to your xml.
Deletehow can I show the drawer in the right side
ReplyDeleteI've tried the layout_gravity and it did not work
android version (1.4)
Hey. This might help you friend https://github.com/kanytu/android-material-drawer-template/issues/22
Deletepedro i have question T how can i make the drawer to open from right to left ?
ReplyDeleteHey. You can check here: https://github.com/kanytu/android-material-drawer-template/issues/22
DeleteJust wanted to thank you for making this.. did better than Google lol...
ReplyDeleteHello, thank you very much for your template . Is it possible to present the menu as follows:
ReplyDeleteTitle :
Item 1
Item 2
Title :
Item 3
Item 4
Thx in advance
Hello Is it possible to use in eclipse ?
ReplyDeleteI 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
DeleteHello,
ReplyDeleteI use your tipps.My program run a device (Xperia Z1 Compact), but it's not working on (normal) Xperia Z. What can I do?
Pedro, sou do Brasil e gostei muito do template. Mas tenho uma duvida, como faço pra botar o Drawer bellow toolbar?
ReplyDeleteGrato!
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.
ReplyDeleteHey 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
DeleteHi 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?
ReplyDeleteHey friend. This was fixed here: https://github.com/kanytu/Android-studio-material-template/commit/5e82be763c135389fe420c357546d69123971002
DeleteHey Pedro,
ReplyDeleteI 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.
Hi friend. Feel free to use that image. As you can see here the image is free:
Deletehttps://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
Really awesome blog. Your blog is really useful for me. Thanks for sharing this informative blog. Keep update your blog.
ReplyDeleteGoogle App Integration Chennai
I'm impressed at your knowledge base....seems you have TREMENDOUS insight...
ReplyDeleteI 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
Hey friend :)
DeleteThank 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
Hi Pedro,
ReplyDeleteThanks 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.
This is one of the best post I have seen recently which has a bunch of informative and useful content.
ReplyDeleteOMG! 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.
ReplyDeleteTo 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.
ReplyDeleteHey Pedro,
ReplyDeleteYou are rocking mann! An amazing post indeed! And I love the way you explained it. Keep going and thanks for the great post.
Great Post! Thanks for sharing the informative stuff in your blog. Keep on updating.
ReplyDeleteAll posts in this blog are always contain a informative stuff. Keep on updating
ReplyDeleteHey! Just an amazing information. Keep on Updating. You are rocking. Thanks for sharing this.
ReplyDeleteOMG! 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.
ReplyDeleteThis blog is full of informative and useful post. Keep on updating.
ReplyDelete