Search code examples
androidgoogle-chromeandroid-fragmentsswipegestures

Android swipe fragment out of screen


I am quite new to Android development and would like to know how I can realize the effect that individual Fragments can be simply swiped away as it's done in the Android Chrome browser's tab overview. What do I need to google for? Currently I have a Navigation Drawer as side-menu and a LinearLayout for the main content with a ScrollView inside, where multiple small Fragments go into.


Solution

  • To do that, simply apply a gesture detector on the view you wish to swipe. When you detect the gesture, run an animation to move the view off to the right or left and then make it disappear.