Snackbar is not dismissing on swipe

后端 未结 4 1890
没有蜡笔的小新
没有蜡笔的小新 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条回答
  •  伪装坚强ぢ
    2021-02-19 03:06

    Snackbar needs a CoordinatorLayout as its root layout or some where on top of it, to perform its various operations like swipe to dismiss. You need to have that some where in your layout hierarchy.

    Further the view that we pass in the Snackbar.make() method is used to search a CoordinatorLayout some where in the view hierarchy. The method traverse from this view to the root view to find a CoordinatorLayout over which it can show the snackbar and perform its animations and operations.

    So try replacing root layout to CoordinatorLayout and your problem will be solved.

提交回复
热议问题