抽屉切换按钮未显示在操作栏上 [英] Drawer toggle button not displaying on Action Bar

查看:101
本文介绍了抽屉切换按钮未显示在操作栏上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序中有两个活动,并且都实现了导航抽屉.现在的场景是,将为第一个活动显示抽屉"开关,但对于相同的代码,不会为第二个活动显示(从第一个活动调用).我在Android编程方面没有太多经验,所以我坚持使用这一程序.请帮助任何人:(

I have two activities in my app and both have navigation drawers implemented. Now the scenario is that the Drawer toggle is getting displayed for the first activity but for the same code its not getting displayed for the second activity (which is getting called from the first activity). I don't have much experience in Android Programming and I am stuck on this one. Please help anyone :(

以下是显示抽屉切换按钮的Java代码段:

DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout_quiz);
        ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
                this, drawer, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
        drawer.setDrawerListener(toggle);
        toggle.syncState();

推荐答案

在努力2天后,我终于找到了问题所在.鼓卷请....

Ok after struggling for 2 days I finally found what the problem was. drum rolls please ....

问题是:草稿版式内的自定义操作栏布局的Z索引.

您听说过..如果您遇到类似的问题,例如您的自定义操作栏布局未显示或抽屉切换按钮未显示第一件事,则应检查操作栏布局是否位于所有菜单下方主要布局以增加其z顺序.

You heard it .. if you are facing similar issues like for example your custom action bar layout is not displaying or your drawer toggle button is not displaying the first thing you should check if your action bar layout is placed down below all your main layouts to increase its z order.

就我而言,我将其放置在抽屉布局的主要布局上方.而且有趣的是,Android Studio的预览窗口仍在显示自定义操作栏,好像它根本不在乎z索引一样.

In my case I placed it above my main layouts in the drawer layout. And the funny thing is Android Studio's preview window was still displaying the custom action bar as if it doesn't even care about the z index.

这篇关于抽屉切换按钮未显示在操作栏上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆