简体   繁体   English

如何隐藏ActionBar,但仍在左上方显示“导航”菜单图标

[英]How to hide ActionBar but still show Navigation menu icon on top left

I try to hide ActionBar in Navigation View by using getSupportActionBar().hide() but it makes menu icon on top left dissapear too, like this : 我尝试通过使用getSupportActionBar().hide()在Navigation View中隐藏ActionBar,但它也会使菜单图标也消失在左上角,如下所示: 在此处输入图片说明

I want it show like this : 我希望它显示如下:

在此处输入图片说明

Could someone give me some advice ? 有人可以给我一些建议吗?

No, you can't because the icon is part of ActionBar . 不,您不能这样做,因为该图标是ActionBar一部分。 You can create ImageView (or Button , ...) and place it at the top-left position and handle click event or use transparent ToolBar 您可以创建ImageView (或Button ,...)并将其放置在左上角并处理click事件,或使用透明的ToolBar

Add a ImageButton and fix it's position to top left corner . 添加一个ImageButton并将其位置固定在左上角。 And handle the click event of the button using OnClickListner ... Simple ... 并使用OnClickListner ... Simple ...处理按钮的click事件。

I have just done it,for anyone need it, just create an ImageView and handle click event with this: 我刚刚完成了它,对于任何需要它的人,只需创建一个ImageView并使用以下命令处理click事件:

DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
drawerLayout.openDrawer(Gravity.LEFT);

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

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