如何在NavigationView打开时隐藏小吃吧?

时间:2017-10-04 08:49:25

标签: android android-navigationview android-snackbar

NavigationView显示时如何隐藏shackbar

因此snackbar不会重叠NavigationView

2 个答案:

答案 0 :(得分:2)

您可以使用Snackbar Callbacks

snackbar.addCallback(new Snackbar.Callback() {

    @Override
    public void onDismissed(Snackbar snackbar, int event) {
      //see Snackbar.Callback docs for event details
      ...  
    }

    @Override
    public void onShown(Snackbar snackbar) {
       drawerLayout.closeDrawer(GravityCompat.START);
    }
  });

答案 1 :(得分:0)

试试这个

  • 此处有two方式close your drawer

    1. close抽屉,animation就像这样
snackbar.addCallback(new Snackbar.Callback() {

@Override
public void onDismissed(Snackbar snackbar, int event) {
  //see Snackbar.Callback docs for event details
  ...  
}

@Override
public void onShown(Snackbar snackbar) {
   drawerLayout.closeDrawer(GravityCompat.START);
}
});
  1. close抽屉没有animation这样的
  2. snackbar.addCallback(new Snackbar.Callback() {
    
    @Override
    public void onDismissed(Snackbar snackbar, int event) {
      //see Snackbar.Callback docs for event details
      ...  
    }
    
    @Override
    public void onShown(Snackbar snackbar) {
       drawerLayout.closeDrawer(GravityCompat.START,false);
    }
    });