Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swipe/drag Android view from the bottom of the screen

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?

This is what I want to have initially

enter image description here

like image 500
stanete Avatar asked Feb 14 '14 16:02

stanete


People also ask

How do I drag view on Android?

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).

How do I swipe back on android?

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.


2 Answers

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

like image 108
Jon Avatar answered Oct 13 '22 11:10

Jon


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

like image 44
Nithish V Avatar answered Oct 13 '22 12:10

Nithish V