android.support.v4.widget.DrawerLayout.closeDrawer()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(5.6k)|赞(0)|评价(0)|浏览(145)

本文整理了Java中android.support.v4.widget.DrawerLayout.closeDrawer()方法的一些代码示例,展示了DrawerLayout.closeDrawer()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DrawerLayout.closeDrawer()方法的具体详情如下:
包路径:android.support.v4.widget.DrawerLayout
类名称:DrawerLayout
方法名:closeDrawer

DrawerLayout.closeDrawer介绍

[英]Close the specified drawer by animating it out of view.
[中]通过在视图外设置指定抽屉的动画将其关闭。

代码示例

代码示例来源:origin: stackoverflow.com

DrawerLayout mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout)
LinearLayout mDrawerLinear = (LinearLayout) findViewById(R.id.left_drawer);
ListView mDrawerListChild = (ListView) findViewById(R.id.left_drawer_child);

...

mDrawer.closeDrawer(mDrawerLinear);

代码示例来源:origin: MindorksOpenSource/android-mvp-architecture

@Override
  public void closeNavigationDrawer() {
    if (mDrawer != null) {
      mDrawer.closeDrawer(Gravity.START);
    }
  }
}

代码示例来源:origin: bingoogolapple/BGARefreshLayout-Android

private void hideDrawer() {
  mDrawerLayout.closeDrawer(GravityCompat.START);
}

代码示例来源: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: frogermcs/InstaMaterial

public void onGlobalMenuHeaderClick(final View v) {
  drawerLayout.closeDrawer(Gravity.LEFT);
  new Handler().postDelayed(new Runnable() {
    @Override
    public void run() {
      int[] startingLocation = new int[2];
      v.getLocationOnScreen(startingLocation);
      startingLocation[0] += v.getWidth() / 2;
      UserProfileActivity.startUserProfileFromLocation(startingLocation, BaseDrawerActivity.this);
      overridePendingTransition(0, 0);
    }
  }, 200);
}

代码示例来源:origin: rey5137/material

@Override
  public void onClick(View v) {
    int position = (Integer)v.getTag();
    vp.setCurrentItem(position);
    dl_navigator.closeDrawer(fl_drawer);
  }
}

代码示例来源:origin: pockethub/PocketHub

private void switchFragment(Fragment fragment, User organization) {
  if (organization != null) {
    Bundle args = new Bundle();
    args.putParcelable("org", organization);
    fragment.setArguments(args);
  }
  FragmentManager manager = getSupportFragmentManager();
  manager.beginTransaction().replace(R.id.container, fragment).commit();
  drawerLayout.closeDrawer(GravityCompat.START);
  currentFragment = fragment;
}

代码示例来源: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: Rukey7/MvpApp

@Override
public boolean onNavigationItemSelected(@NonNull final MenuItem item) {
  mDrawerLayout.closeDrawer(GravityCompat.START);
  if (item.isChecked()) {
    return true;
  }
  mItemId = item.getItemId();
  return true;
}

代码示例来源: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: BaronZ88/MinimalistWeather

@Override
  public void onSelect(String cityId) {

    assert drawerLayout != null;
    drawerLayout.closeDrawer(GravityCompat.START);

    new Handler().postDelayed(() -> homePagePresenter.loadWeather(cityId, false), 250);
  }
}

代码示例来源: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: robolectric/robolectric

/** Drawer animations are disabled in unit tests. */
 @Implementation
 protected void closeDrawer(View drawerView, boolean animate) {
  directlyOn(realDrawerLayout, DrawerLayout.class).closeDrawer(drawerView, false);
 }
}

代码示例来源: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: naman14/Timber

@Override
public void onBackPressed() {
  if (panelLayout.isPanelExpanded()) {
    panelLayout.collapsePanel();
  } else if (mDrawerLayout.isDrawerOpen(GravityCompat.START)) {
    mDrawerLayout.closeDrawer(GravityCompat.START);
  } else {
    super.onBackPressed();
  }
}

相关文章