I want to do in my app a View that I can swipe from the bottom of the window (Images below explain it better).
I want the view to stop at certain point. The view must allow to swipe/drag it to the bottom again. Any idea or tip of how can I do that?
A drag and drop operation starts when the user makes a UI gesture that your app recognizes as a signal to start dragging data. In response, the app notifies the system that a drag and drop operation is starting. The system calls back to your app to get a representation of the data being dragged (a drag shadow).
Tap the Settings button next to Gesture navigation to change the sensitivity of the screen to the Back swipe gesture. If you find that gestures aren't being recognised, use the Left edge and Right edge sliders to turn the sensitivity upwards. If you're using gestures unintentionally, turn the sensitivity down.
I think you are in search of a ViewDragHelper
:
API doc: https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper.html
How to use. This answer links to a sample project to show you how as well: ViewDragHelper: how to use it?
Dragging best practices:
http://developer.android.com/training/gestures/scale.html
You can use the new material design pattern called Bottom Sheets. They do the exact thing that you want. They also support custom layouts for the view.
Material Design - Component - Bottom Sheets
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With