{"id":21130129,"url":"https://github.com/jmartinesp/GoogleNavigationDrawerMenu","last_synced_at":"2025-07-09T01:32:27.179Z","repository":{"id":16049304,"uuid":"18793303","full_name":"jmartinesp/GoogleNavigationDrawerMenu","owner":"jmartinesp","description":"Android Library for a DrawerLayout similar to the one in Google Apps","archived":false,"fork":false,"pushed_at":"2017-04-18T06:04:24.000Z","size":449,"stargazers_count":270,"open_issues_count":5,"forks_count":76,"subscribers_count":21,"default_branch":"master","last_synced_at":"2024-11-13T05:35:54.758Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jmartinesp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-04-15T08:45:33.000Z","updated_at":"2024-03-02T18:57:05.000Z","dependencies_parsed_at":"2022-09-02T13:01:33.497Z","dependency_job_id":null,"html_url":"https://github.com/jmartinesp/GoogleNavigationDrawerMenu","commit_stats":null,"previous_names":["arasthel/googlenavigationdrawermenu"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmartinesp%2FGoogleNavigationDrawerMenu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmartinesp%2FGoogleNavigationDrawerMenu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmartinesp%2FGoogleNavigationDrawerMenu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmartinesp%2FGoogleNavigationDrawerMenu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jmartinesp","download_url":"https://codeload.github.com/jmartinesp/GoogleNavigationDrawerMenu/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225476373,"owners_count":17480215,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-20T05:32:18.314Z","updated_at":"2024-11-20T05:32:25.919Z","avatar_url":"https://github.com/jmartinesp.png","language":"Java","funding_links":[],"categories":["Libs"],"sub_categories":["\u003cA NAME=\"Widget\"\u003e\u003c/A\u003eWidget"],"readme":"# GoogleNavigationDrawerMenu\n\nThis project aims to let you use a ListView menu similar to the one in the new Google Apps (Keep, Play Music...) without having to do any extra effort. Sorry for the long name, though.\n\n![Screenshot](GoogleNavigationDrawer.jpg)\n\n## Index\n* [Features](#features)\n* [How to use](#how-to-use)\n    1. [Include the library](#1-include-the-library)\n    2. [Use class in XML or code](#2-use-class-in-xml-or-code)\n    3. [Handling selection](#3-handling-selection-opening-and-closing-of-the-menu)\n    4. [Customizing the inner ListView](#4-customizing-the-inner-listview)\n* [License](#license)\n\n## Features\n\nWith GoogleNavigationDrawerMenu you can:\n\n  * Set a GoogleApp-styled DrawerLayout menu and only have to specify the main content for your app, you no longer have set the ListView and its styles. Everything is handled by the **GoogleNavigationDrawer** class.\n  * Set main and secondary sections to the menu.\n  * Set a list of icons for those sections (optional).\n  * Both text and icons remain selected when you click on them.\n  * Set an *OnNavigationSectionSelected* listener so you can handle section selection events.\n  * Change the background of the list items.\n  * Set a header and footer to the inner ListView.\n\n## How to use\n\n### 1. Include the library:\n\n  **Manually (Option A):**\n\n  Download the source code and import ```GoogleNavigationDrawerMenuLibrary``` folder as a Library Module in Android Studio or as a Project in Eclipse (still not tested).\n\n  **Manually (Option B):**\n\n  * Download the [AAR](aars/GoogleNavigationDrawerMenuLibrary.aar?raw=true).\n  * Put it in the ```aars``` folder of your Android Studio project.\n  * Add a File Dependency or add it to the ```build.gradle``` of your main Module, like this:\n\n        repositories {\n          mavenCentral()\n          flatDir {\n              dirs 'aars'\n          }\n        }\n\n  Notice the ```flatDir``` local maven repository created. Now you will have to add the aar file to the *dependencies* list, as if you were adding it from Maven Central Repository:\n\n        compile 'com.arasthel:gnavdrawer-library:+'\n\n\n**Automatic (Gradle):**\n\nAdd it to your Application Module's `build.gradle`:\n\nDeclare it into your build.gradle\n\n    dependencies{\n        compile 'com.arasthel:gnavdrawer-library:+'\n    }\n\n### 2. Use class in XML or code:\n\n#### Example of how to use it on an XML code:\n\n```xml\n\u003corg.arasthel.googlenavdrawermenu.views.GoogleNavigationDrawer\nxmlns:android=\"http://schemas.android.com/apk/res/android\"\nxmlns:drawer=\"http://schemas.android.com/apk/res-auto\"\nandroid:id=\"@+id/navigation_drawer_container\"\nandroid:layout_width=\"match_parent\"\nandroid:layout_height=\"match_parent\"\ndrawer:list_paddingTop=\"?android:actionBarSize\"\ndrawer:drawer_gravity=\"start\"\ndrawer:list_mainSectionsEntries=\"@array/navigation_main_sections\"\ndrawer:list_secondarySectionsEntries=\"@array/navigation_secondary_sections\"\ndrawer:list_mainSectionsDrawables=\"@array/drawable_ids\"\ndrawer:list_secondarySectionsDrawables=\"@array/drawable_ids\"\u003e\n\n  \u003cFrameLayout\n      android:id=\"@+id/content_layout\"\n      android:layout_width=\"match_parent\"\n      android:layout_height=\"match_parent\"/\u003e\n\n\u003c/org.arasthel.googlenavdrawermenu.views.GoogleNavigationDrawer\u003e\n```\n\nYou may think *'Ok, so where's the menu?'*. Well, the GoogleNavigationDrawer class itself contains it and handles it so you don't have to manually modify it. You can customize it, though, you can find that info in [**Customizing Section**](#4-customizing-the-inner-listview).\n\nAll the `drawer:*` attributes are optional, but if you don't provide any entries you will have to do it later in code with `drawer.setListViewSections(...)`.\n\n#### Using GoogleNavigationDrawer in Java Code:\n\n```java\nViewGroup container = (ViewGroup) findViewById(R.id.container);\nGoogleNavigationDrawer drawer = new GoogleNavigationDrawer(context);\n// Here we are providing data to the adapter of the ListView\ndrawer.setListViewSections(new String[]{\"Section A\", \"Section B\"}, // Main sections\n        new String[]{\"Settings\"}, // Secondary sections\n        new int[]{R.drawable.ic_launcher}, // Main sections icon ids\n        null); // Secondary sections icon ids\n// To work correctly, a DrawerLayout must be the only View in a ViewGroup\ncontainer.removeAllViews();\ncontainer.addView(drawer);\n// Now we add the content to the drawer since the menu is already there.\n// Also, DrawerLayout forces the contentView to be the first item. Otherwise, you can't click on the menu.\ndrawer.addView(contentView, 0);\n```\n\n\nGoogleNavigationDrawer extends DrawerLayout. This means you can use DrawerLayout methods and set a DrawerListener to it.\n\n### 3. Handling selection, opening and closing of the menu:\n\n As you cannot access the inner ListView to ensure encapsulation, additional methods have been provided so you can do it by code. This methods are:\n\n```java\npublic boolean isDrawerMenuOpen();\n\npublic void openDrawerMenu();\n\npublic void closeDrawerMenu();\n```\n\nAlso, to handle section selections, a listener has been provided:\n\n```java\npublic void setOnNavigationSectionSelected(OnNavigationSectionSelected listener);\n```\nYou can also easily tell the drawer to change your Activity title based on the selected section via this method:\n\n```java\npublic void setShouldChangeTitle(Activity activity, boolean shouldChangeTitle);\n```\n\n### 4. Customizing the inner ListView:\n\n Finally, customization. The main XML attributes of the class are the following:\n\n```xml\ndrawer:list_padding[Top, Bottom, Left, Right]=\"dimen\"\ndrawer:drawer_gravity=\"start\"\ndrawer:list_mainSectionsEntries=\"array\"\ndrawer:list_secondarySectionsEntries=\"array\"\ndrawer:list_mainSectionsDrawables=\"array\"\ndrawer:list_secondarySectionsDrawables=\"array\"\ndrawer:list_headerView=\"layout\"\ndrawer:list_footerView=\"layout\"\ndrawer:list_headerClickable=\"boolean\" (default is true)\ndrawer:list_footerClickable=\"boolean\" (default is true)\ndrawer:list_secondarySectionsCheckable=\"boolean\" (default is true)\ndrawer:list_mainSectionsBackground=\"drawable\"\ndrawer:list_secondarySectionsBackground=\"drawable\"\ndrawer:list_width=\"dimension\"\ndrawer:list_background=\"drawable|color\"\ndrawer:list_[main|secondary]_divider=\"drawable|color\"\ndrawer:list_[main|secondary]_divider_height=\"dimension\"\n```\n\n\nExample of *arrays* in ```arrays.xml```:\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003cresources\u003e\n\n    \u003cstring-array name=\"navigation_main_sections\"\u003e\n        \u003citem\u003eHome\u003c/item\u003e\n        \u003citem\u003eSome Other\u003c/item\u003e\n    \u003c/string-array\u003e\n\n    \u003cstring-array name=\"navigation_secondary_sections\"\u003e\n        \u003citem\u003eSettings\u003c/item\u003e\n        \u003citem\u003eInfo\u003c/item\u003e\n    \u003c/string-array\u003e\n\n    \u003carray name=\"drawable_ids\"\u003e\n        \u003citem\u003e@drawable/ic_home\u003c/item\u003e\n        \u003citem\u003e@drawable/ic_other\u003c/item\u003e\n    \u003c/array\u003e\n\n\u003c/resources\u003e\n```\n\nAlso, both icon drawables and backgrounds **should have checked states** to keep them consistent with the rest of the library:\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\n\u003cselector xmlns:android=\"http://schemas.android.com/apk/res/android\"\u003e\n    \u003citem android:state_checked=\"true\" android:drawable=\"@drawable/ic_on\"\u003e\u003c/item\u003e\n    \u003citem android:drawable=\"@drawable/ic_off\"\u003e\u003c/item\u003e\n\u003c/selector\u003e\n```\n\nAll these attributes can also be set by code.\n\n## License:\n\nThis library is licensed under Apachev2:\n\n\u003eLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License.\n\u003eYou may obtain a copy of the License at\n\n\u003e    http://www.apache.org/licenses/LICENSE-2.0\n\n\u003eUnless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\u003eSee the License for the specific language governing permissions and limitations under the License.\n\nThis means you can use the library in whatever way you want and also I take no responsibility of what it could do (thermo-nuclear explosions and such).\n\nAnyway, it would be really nice of you if you could give this library a line in some \"About\" section in your app.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmartinesp%2FGoogleNavigationDrawerMenu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjmartinesp%2FGoogleNavigationDrawerMenu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmartinesp%2FGoogleNavigationDrawerMenu/lists"}