-1

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?

A. Steenbergen
  • 3,360
  • 4
  • 34
  • 51
  • The `DrawerListener` interface provides an `onDrawerSlide()` method that has an offset parameter, indicating the fraction of its width a Drawer is open. It doesn't provide any way to determine a y-coordinate, though, if that is indeed necessary. – Mike M. Dec 12 '14 at 00:55
  • 1
    An offset will work! Would you mind posting this again as a reply, so I can accept it as an answer? Thanks! – A. Steenbergen Dec 12 '14 at 00:57

1 Answers1

1

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);
    ...
}
Mike M.
  • 38,532
  • 8
  • 99
  • 95