Android DrawerLayout listen for user dragging?

820 Views Asked by At

I am looking for a way to listen for the user opening the DrawerLayout by dragging his finger, so I can read its current x and y values. Something more 'in-depth' than simple open and close events from a DrawerListener.

My idea would be to implement a separate onTouchListener on the whole Activity and calculate drawer openings from intercepted touch events there but I would like to use a simpler approach if it exists.

Something like an onScrollListener or an onTouchListener where I can get the Drawer's current x and y or translationX and translationY values?

1

There are 1 best solutions below

0
On BEST ANSWER

The DrawerListener interface provides an onDrawerSlide() method that has an offset parameter, indicating the fraction of its width a Drawer is open.

public static abstract interface DrawerListener
{
    public abstract void onDrawerSlide(android.view.View drawerView, float slideOffset);
    ...
}