Android 没有操作栏的导航抽屉
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20971245/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Navigation Drawer without Actionbar
提问by Chinmay Dabke
I searched many sites (stackoverflow as well) but couldn't understand how to implement the navigation drawer without the action bar. I know that this question has already been asked here but it doesn't have a proper explanation and code. I am a beginner in android development so can anyone please explain me with code How to make a navigation drawer without an action bar
我搜索了许多站点(也包括 stackoverflow),但无法理解如何在没有操作栏的情况下实现导航抽屉。我知道这里已经有人问过这个问题,但没有正确的解释和代码。我是 android 开发的初学者,所以任何人都可以用代码向我解释如何制作没有操作栏的导航抽屉
Thanks in advance!
提前致谢!
回答by Mehdiway
Just add your DrawerLayout
like @mohan did, then if you have a button or something you tap on and want to open the drawer, just do like this :
只需添加您DrawerLayout
像@mohan 所做的那样,然后如果您有一个按钮或想要打开抽屉的东西,请执行以下操作:
drawer.openDrawer(Gravity.LEFT);
and to close :
并关闭:
drawer.closeDrawer(Gravity.LEFT);
回答by Kim Sant
Starting from the Sample Android NavigationDrawer app:
从示例 Android NavigationDrawer 应用程序开始:
- Use the Activity theme: Theme.NoTitleBar
- Erase all the ActionBar references in the code
Create a button and in the clickListener call:
drawer.openDrawer(Gravity.LEFT);
- 使用活动主题:Theme.NoTitleBar
- 擦除代码中的所有 ActionBar 引用
创建一个按钮并在 clickListener 调用中:
drawer.openDrawer(Gravity.LEFT);