Snackbar is not dismissing on swipe

后端 未结 4 1896
没有蜡笔的小新
没有蜡笔的小新 2021-02-19 02:39

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

4条回答
  •  梦毁少年i
    2021-02-19 03:09

    Snackbars in my GLSurfaceView game don't dismiss with a swipe, and users may not know to swipe anyway if they did. The following one line of code dismisses a Snackbar with any touch of the bar. Critically I found if the user does happen to hit the action button if it has one, whatever action it is set to do is still performed. The overall dismiss does not get in the way.

    snackbar.getView().setOnClickListener(view -> snackbar.dismiss());
    

提交回复
热议问题