我想在单击FAB按钮的同时打开导航抽屉。

怎么做?

最佳答案

你可以看看这个DrawerLayout

mDrawerLayout = (DrawerLayout) getView().findViewById(R.id.drawer_layout);

FloatingActionButton myFab = (FloatingActionButton) myView.findViewById(R.id.myFAB);
myFab.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {
       //if you need open the slide:
       mDrawerLayout.openDrawer(Gravity.LEFT);

       //if you need close the slide
       mDrawerLayout.closeDrawer(Gravity.LEFT);
    }
});

10-01 08:26