Skip to content

Instantly share code, notes, and snippets.

@shem8
Created April 25, 2016 05:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shem8/5bf21b24c8eca00b08daf782921e4f4a to your computer and use it in GitHub Desktop.
Save shem8/5bf21b24c8eca00b08daf782921e4f4a to your computer and use it in GitHub Desktop.
View dismiss = findViewById(R.id.dismiss);
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) dismiss.getLayoutParams();
SwipeDismissBehavior<View> behavior = new SwipeDismissBehavior<>();
behavior.setSwipeDirection(SwipeDismissBehavior.SWIPE_DIRECTION_START_TO_END);
behavior.setListener(new SwipeDismissBehavior.OnDismissListener() {
@Override
public void onDismiss(final View view) {
finish();
}
@Override
public void onDragStateChanged(int i) {}
});
params.setBehavior(behavior);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment