Search code examples
androidhidetapslidingdrawer

hide SlidingDrawer on screen tap


By default, in Android SlidingDrawer designed to use a child view as a handle to open or hide its self. But here want to hide my SlidingDrawer by tapping on any place on the screen that are not inside the opening SlidingDrawer area. Just like a pop-up menu hides when user taps on other places on desktop/web based app. Any way to do that? My slidingDrawer is made to be not full screen, so it allows user to tap on other places on the screen.


Solution

  • On the view that is outside the sliding drawer, Add a TouchListener in which you call slidingDrawer.close(); or slidingDrawer.animateClose(); on the sliding drawer.