简体   繁体   English

导航抽屉的不同视图

[英]navigation drawer on different views

If I create a navigation drawer without nothing, it works perfectly. 如果我创建一个没有任何内容的导航抽屉,它会完美工作。 If ie I call 如果我打电话给

setContentView(R.layout.screen_one);

for to show another screen, the navigation drawer doesn't work anymore. 要显示另一个屏幕,导航抽屉将不再起作用。 I press the button on the action bar but nothing to do. 我按下操作栏上的按钮,但无济于事。

Where is the mistake? 错误在哪里? Thanks 谢谢

I think you are calling this 我想你是在打电话

setContentView(R.layout.screen_one);

in a new class/activity. 在新的班级/活动中。

This new screen when you call, it sits on top of your old screen. 呼叫时,此新屏幕位于旧屏幕的顶部。 But your navigation drawer is attached to previous screen, so it doesn't work as all your touch events are happening on the new screen. 但是您的导航抽屉已连接到先前的屏幕,因此它不起作用,因为所有触摸事件都在新屏幕上发生。

Check out this Nav Drawer implementation sample according to Material Design . 根据Material Design来检查此Nav Drawer实现示例

If you have doubts about it just check out this 3 articles about it. 如果您对此有疑问,请查看有关此的3篇文章。

  1. Material Design Nav Drawer: Sizing 物料设计导航抽屉:调整尺寸
  2. Material Design Nav Drawer: Styling 物料设计导航抽屉:样式
  3. Material Design Nav Drawer: Navigating 材质设计导航抽屉:导航

It's recommended to use the Android Support Design library that will make your life easy. 建议使用Android支持设计库 ,这将使您的生活变得轻松。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM