如何检测导航抽屉是否打开? [英] How to detect if navigation drawer is open?

查看:82
本文介绍了如何检测导航抽屉是否打开?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

标题说明了一切.我要做的就是知道导航抽屉是否打开.我在网上进行了很多搜索,发现了方法isDrawerOpen(int drawerGravity),但找不到令人满意的答案,该答案解释了如何在方法中使用它.如果有人向我解释,我将不胜感激.

The title explains it all. All what I want to do is to know if the navigation drawer is open or not. I searched a lot on the net and found the method isDrawerOpen(int drawerGravity)but couldn't find a satisfactory answer which explains how to use it in a method. I would appreciate if anyone explains it to me.

提前谢谢!

推荐答案

假定您已在xml中定义了一个抽屉布局:

Assuming you have defined a drawerlayout in xml:

DrawerLayout mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
...
if(mDrawerLayout.isDrawerOpen(GravityCompat.START)) {
  //drawer is open
}

这篇关于如何检测导航抽屉是否打开?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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