Rileva DrawerLayout
aperto, chiuso, scorrevole DrawerLayout.DrawerListener
DrawerLayout drawerLayout:
drawerLayout.addDrawerListener(new DrawerLayout.DrawerListener() {
/**
* Called when a drawer's position changes.
*
* @param slideOffset The new offset of this drawer within its range, from 0-1
* Example when you slide drawer from left to right, slideOffset will increase from 0 - 1 (0 when drawer closed and 1 when drawer display full)
*/
@Override
public void onDrawerSlide(@NonNull View drawerView, float slideOffset) {
}
@Override
public void onDrawerOpened(@NonNull View drawerView) {
// do something when drawer opened
}
@Override
public void onDrawerClosed(@NonNull View drawerView) {
// do something when drawer closed
}
/**
* Called when the drawer motion state changes. The new state will
* be one of {@link #STATE_IDLE}, {@link #STATE_DRAGGING} or {@link #STATE_SETTLING}.
*/
@Override
public void onDrawerStateChanged(int newState) {
}
});
Verificare che il cassetto sia aperto
if(drawerLayout.isDrawerOpen(GravityCompat.START)) // or GravityCompat.END
boolean drawerOpen = mDrawerLayout.isDrawerOpen(mDrawerList)
. mDrawerLayout è il drawer e mDrawerList è il listview