本文整理了Java中android.support.v4.widget.DrawerLayout.isDrawerOpen()
方法的一些代码示例,展示了DrawerLayout.isDrawerOpen()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DrawerLayout.isDrawerOpen()
方法的具体详情如下:
包路径:android.support.v4.widget.DrawerLayout
类名称:DrawerLayout
方法名:isDrawerOpen
[英]Check if the given drawer view is currently in an open state. To be considered "open" the drawer must have settled into its fully visible state. If there is no drawer with the given gravity this method will return false.
[中]检查给定的抽屉视图当前是否处于打开状态。要被视为“打开”,抽屉必须处于完全可见的状态。若并没有具有给定重力的抽屉,该方法将返回false。
代码示例来源:origin: stackoverflow.com
DrawerLayout mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
...
if(mDrawerLayout.isDrawerOpen(GravityCompat.START)) {
//drawer is open
}
代码示例来源:origin: stackoverflow.com
@Override
public void onBackPressed() {
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
}
if (!viewIsAtHome) { //if the current view is not the News fragment
displayView(R.id.nav_news); //display the News fragment
} else {
moveTaskToBack(true); //If view is in News fragment, exit application
}
}
代码示例来源:origin: stackoverflow.com
DrawerLayout drawer...
@Override
public void onBackPressed() {
// TODO Auto-generated method stub
if(drawer.isDrawerOpen(Gravity.LEFT)){
drawer.closeDrawer(Gravity.LEFT);
}else{
super.onBackPressed();
}
}
代码示例来源:origin: Clans/FloatingActionButton
@Override
public void onBackPressed() {
if (mDrawerLayout != null && mDrawerLayout.isDrawerOpen(GravityCompat.START)) {
mDrawerLayout.closeDrawer(GravityCompat.START);
} else {
super.onBackPressed();
}
}
}
代码示例来源:origin: HotBitmapGG/bilibili-android-client
/**
* DrawerLayout侧滑菜单开关
*/
public void toggleDrawer() {
if (mDrawerLayout.isDrawerOpen(GravityCompat.START)) {
mDrawerLayout.closeDrawer(GravityCompat.START);
} else {
mDrawerLayout.openDrawer(GravityCompat.START);
}
}
代码示例来源:origin: fython/MaterialStepperView
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
if (mDrawerLayout.isDrawerOpen(mNavigationView)) {
mDrawerLayout.closeDrawer(mNavigationView);
} else {
mDrawerLayout.openDrawer(mNavigationView);
}
return true;
default:
return false;
}
}
代码示例来源:origin: rey5137/material
@Override
public boolean isBackState() {
return mFragmentManager.getBackStackEntryCount() > 1 || (mDrawerLayout != null && mDrawerLayout.isDrawerOpen(GravityCompat.START));
}
代码示例来源:origin: JohnPersano/SuperToasts
@Override
public void onBackPressed() {
final DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
if (drawer.isDrawerOpen(GravityCompat.START)) drawer.closeDrawer(GravityCompat.START);
else super.onBackPressed();
}
代码示例来源:origin: iammert/MaterialIntroView
@Override
public void onBackPressed() {
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
} else {
super.onBackPressed();
}
}
代码示例来源:origin: iammert/MaterialIntroView
@Override
public void onBackPressed() {
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
} else {
super.onBackPressed();
}
}
代码示例来源:origin: EverythingMe/overscroll-decor
@Override
public void onBackPressed() {
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
} else {
super.onBackPressed();
}
}
代码示例来源:origin: xinghongfei/LookLook
@Override
public void onBackPressed() {
if (drawer.isDrawerOpen(GravityCompat.END)) {
drawer.closeDrawer(GravityCompat.END);
} else {
if ((System.currentTimeMillis() - exitTime) > 2000) {
Toast.makeText(MainActivity.this, "再点一次,退出", Toast.LENGTH_SHORT).show();
exitTime = System.currentTimeMillis();
} else {
super.onBackPressed();
}
}
}
代码示例来源:origin: mancj/MaterialSearchBar
@Override
public void onBackPressed() {
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
} else {
super.onBackPressed();
}
}
代码示例来源:origin: BaronZ88/MinimalistWeather
@Override
public void onBackPressed() {
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
assert drawer != null;
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
} else {
super.onBackPressed();
}
}
代码示例来源:origin: bingoogolapple/BGARefreshLayout-Android
@Override
public void onBackPressed() {
if (mDrawerLayout.isDrawerOpen(GravityCompat.START)) {
hideDrawer();
} else {
super.onBackPressed();
}
}
代码示例来源:origin: naman14/Timber
@Override
public void onBackPressed() {
if (panelLayout.isPanelExpanded()) {
panelLayout.collapsePanel();
} else if (mDrawerLayout.isDrawerOpen(GravityCompat.START)) {
mDrawerLayout.closeDrawer(GravityCompat.START);
} else {
super.onBackPressed();
}
}
代码示例来源:origin: north2016/T-MVP
@Override
public void onBackPressed() {
if (mViewBinding.dlMainDrawer.isDrawerOpen(Gravity.LEFT))
mViewBinding.dlMainDrawer.closeDrawers();
else super.onBackPressed();
}
代码示例来源:origin: joyoyao/superCleanMaster
@Override
public void onDrawerSlide(View drawerView, float slideOffset) {
if (mDrawerImage == null) {
super.onDrawerSlide(drawerView, slideOffset);
return;
}
if (animateEnabled) {
mDrawerImage.setVerticalMirror(!mDrawerLayout.isDrawerOpen(GravityCompat.START));
mDrawerImage.setProgress(slideOffset);
}
}
代码示例来源:origin: rey5137/material
/**
* Handling onDrawerSlide event of DrawerLayout. It'll sync progress of drawer sliding animation with navigation state changing animation if needed.
* If you also want to handle this event, make sure to call super method.
*/
protected void onDrawerSlide(View drawerView, float slideOffset){
if(!shouldSyncDrawerSlidingProgress()){
notifyStateInvalidated();
}
else {
if (mDrawerLayout.isDrawerOpen(GravityCompat.START))
notifyStateProgressChanged(false, 1f - slideOffset);
else
notifyStateProgressChanged(true, slideOffset);
}
}
代码示例来源:origin: hidroh/materialistic
@Override
public void onBackPressed() {
if (mDrawerLayout.isDrawerOpen(mDrawer)) {
closeDrawers();
} else if (isTaskRoot() && Preferences.isLaunchScreenLast(this)) {
moveTaskToBack(true);
} else {
super.onBackPressed();
}
}
内容来源于网络,如有侵权,请联系作者删除!