Android CoordinatorLayout and Behaviors edit

Using the SwipeDismissBehavior

The SwipeDismissBehavior works on any View and implements the functionality of swipe to dismiss in our layouts with a CoordinatorLayout.

Just use:

final SwipeDismissBehavior<MyView> swipe = new SwipeDismissBehavior();

//Sets the swipe direction for this behavior.
swipe.setSwipeDirection(
    SwipeDismissBehavior.SWIPE_DIRECTION_ANY);

//Set the listener to be used when a dismiss event occurs
swipe.setListener(
    new SwipeDismissBehavior.OnDismissListener() {
    @Override public void onDismiss(View view) {
        //......
    }

    @Override 
    public void onDragStateChanged(int state) {
        //......
    }
});

//Attach the SwipeDismissBehavior to a view
LayoutParams coordinatorParams = 
    (LayoutParams) mView.getLayoutParams();    
coordinatorParams.setBehavior(swipe);

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


Table Of Contents
39 ACRA
64 Menu
112 Loader
119 Xposed
132 Colors
135 Fresco
140 AdMob
147 Button
150 CoordinatorLayout and Behaviors
156 Vk SDK
170 XMPP
176 OpenCV
200 FileIO
203 Moshi
217 Paint
231 AIDL
241 JCodec
243 Okio
255 Looper
  ↑ ↓ to navigate     ↵ to select     Esc to close