{"id":13514947,"url":"https://github.com/yarolegovich/SlidingRootNav","last_synced_at":"2025-03-31T04:36:05.100Z","repository":{"id":38326048,"uuid":"86270752","full_name":"yarolegovich/SlidingRootNav","owner":"yarolegovich","description":"DrawerLayout-like ViewGroup, where a \"drawer\" is hidden under the content view, which can be shifted to make the drawer visible.","archived":false,"fork":false,"pushed_at":"2022-07-22T06:15:58.000Z","size":10856,"stargazers_count":3061,"open_issues_count":56,"forks_count":454,"subscribers_count":67,"default_branch":"master","last_synced_at":"2025-03-29T21:02:24.424Z","etag":null,"topics":["android","android-development","android-ui","drawer-layout","drawerlayout","nav","navigation-drawer","side-menu","sidemenu","sidenav","sidenavigation","swipe","view"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yarolegovich.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-26T22:58:48.000Z","updated_at":"2025-03-29T20:31:37.000Z","dependencies_parsed_at":"2022-08-09T03:00:44.114Z","dependency_job_id":null,"html_url":"https://github.com/yarolegovich/SlidingRootNav","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yarolegovich%2FSlidingRootNav","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yarolegovich%2FSlidingRootNav/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yarolegovich%2FSlidingRootNav/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yarolegovich%2FSlidingRootNav/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yarolegovich","download_url":"https://codeload.github.com/yarolegovich/SlidingRootNav/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246418658,"owners_count":20773934,"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":["android","android-development","android-ui","drawer-layout","drawerlayout","nav","navigation-drawer","side-menu","sidemenu","sidenav","sidenavigation","swipe","view"],"created_at":"2024-08-01T05:01:04.259Z","updated_at":"2025-03-31T04:36:05.029Z","avatar_url":"https://github.com/yarolegovich.png","language":"Java","funding_links":[],"categories":["Java","抽屉菜单"],"sub_categories":[],"readme":"# SlidingRootNav\n\nThe library is a DrawerLayout-like ViewGroup, where a \"drawer\" is hidden under the content view, which can be shifted to make the drawer visible. It doesn't provide you with a drawer builder.\n\n![GifSample](art/sample.gif)\n\n## Gradle \nAdd this into your dependencies block.\n```\ncompile 'com.yarolegovich:sliding-root-nav:1.1.1'\n```\n## Sample\nPlease see the [sample app](sample/src/main/java/com/yarolegovich/slidingrootnav/sample) for a library usage example.\n\n## Wiki\n#### Usage:\n 1. Create your content_view.xml ([example](sample/src/main/res/layout/activity_main.xml)) or construct a `View` programatically.\n 2. Set the content view (for example, using `setContentView` in your activity).\n 3. Create your menu.xml ([example](sample/src/main/res/layout/menu_left_drawer.xml)) or construct a `View` programatically.\n 4. Now you need to inject the menu in your `onCreate`. You can specify transformations of a content view or use the default ones. \n```java\nnew SlidingRootNavBuilder(this)\n  .withMenuLayout(R.layout.menu_left_drawer)\n  .inject();\n```\n\n### API\n#### Transformations\nYou can specify root transformations using `SlidingRootNavBuilder`.\n```java\nnew SlidingRootNavBuilder(this)\n  .withDragDistance(140) //Horizontal translation of a view. Default == 180dp\n  .withRootViewScale(0.7f) //Content view's scale will be interpolated between 1f and 0.7f. Default == 0.65f;\n  .withRootViewElevation(10) //Content view's elevation will be interpolated between 0 and 10dp. Default == 8.\n  .withRootViewYTranslation(4) //Content view's translationY will be interpolated between 0 and 4. Default == 0\n  .addRootTransformation(customTransformation)\n  .inject();\n```\n`customTransformation` in the above example is a user-created class that implements `RootTransformation` interface. For an example, refer to the [default transformations](library/src/main/java/com/yarolegovich/slidingrootnav/transform). \n\n#### Menu behavior\n```java\nnew SlidingRootNavBuilder(this)\n  .withMenuOpened(true) //Initial menu opened/closed state. Default == false\n  .withMenuLocked(false) //If true, a user can't open or close the menu. Default == false.\n  .withGravity(SlideGravity.LEFT) //If LEFT you can swipe a menu from left to right, if RIGHT - the direction is opposite. \n  .withSavedState(savedInstanceState) //If you call the method, layout will restore its opened/closed state\n  .withContentClickableWhenMenuOpened(isClickable) //Pretty self-descriptive. Builder Default == true\n```\n#### Controling the layout\nA call to `inject()` returns you an interface for controlling the layout.\n```java\npublic interface SlidingRootNav {\n    boolean isMenuClosed();\n    boolean isMenuOpened();\n    boolean isMenuLocked();\n    void closeMenu();\n    void closeMenu(boolean animated);\n    void openMenu();\n    void openMenu(boolean animated);\n    void setMenuLocked(boolean locked);\n    SlidingRootNavLayout getLayout(); //If for some reason you need to work directly with layout - you can\n}\n```\n\n#### Callbacks\n* Drag progress:\n```java\nbuilder.addDragListener(listener);\n\npublic interface DragListener {\n  void onDrag(float progress); //Float between 0 and 1, where 1 is a fully visible menu\n}\n\n```\n* Drag state changes:\n```java\nbuilder.addDragStateListener(listener);\n\npublic interface DragStateListener {\n  void onDragStart();\n  void onDragEnd(boolean isMenuOpened);\n}\n```\n\n* Compatibility with `DrawerLayout.DrawerListener`:\n```java\nDrawerListenerAdapter adapter = new DrawerListenerAdapter(yourDrawerListener, viewToPassAsDrawer);\nbuilder.addDragListener(listenerAdapter).addDragStateListener(listenerAdapter);\n```\n\n## Special thanks\nThanks to [Tayisiya Yurkiv](https://www.behance.net/yurkivt) for a beautiful GIF.\n\n## License\n```\nCopyright 2017 Yaroslav Shevchuk\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyarolegovich%2FSlidingRootNav","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyarolegovich%2FSlidingRootNav","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyarolegovich%2FSlidingRootNav/lists"}