i have a snackbar in my appcompat activity. It has a button OK which dismiss the snackbar.It is working perfact. but i can\'t dismiss the snackbar on swipe(left to right).
As a reference to Ashwani Kumars answer.
I saw Intimate asked if there is a way to implement this with LinearLayout. Well simple wrap your original LinearLayout with a CoordinatorLayout with
match_parent
in android:layout_height
and android:layout_width
attributes.
this will keep your original arrangement and still make sure the Snackbar is swipable.
Snackbar will now look like this:
For fragments -
Snackbar.make(getView(), "Error Message", Snackbar.LENGTH_INDEFINITE);
For activities -
Snackbar.make(this.findViewById(android.R.id.content), "Error Message", Snackbar.LENGTH_INDEFINITE);
Assuming you wraped your whole layout with CoordinatorLayout and this is the root layout.