Android - Snackbar vs Toast - usage and difference

前端 未结 9 1970
温柔的废话
温柔的废话 2020-12-08 03:28

We have been using just Toasts in our application so far and as we are planning to adopt some new features from Support Design Library I am wondering what\'s the recommended

9条回答
  •  死守一世寂寞
    2020-12-08 04:17

    I would like to add a small comparison between toast and snack bar. In my opinion if your intention is to present a warning or info that need user interaction/acknowledgement, you should use a snack bar. If it is just an info message that doesn't need any user acknowledgement you can use toast.

    +---+----------------------------------------------------------------------+--------------------------------------------------------------------------+
    | # |                                Toast                                 |                                 Snackbar                                 |
    +---+----------------------------------------------------------------------+--------------------------------------------------------------------------+
    | 1 | Can’t be dismissed by swiping                                        | Can dismiss by swiping                                                   |
    | 2 | Activity not required (Can show in android home or above other apps) | Can show inside an activity of your app                                  |
    | 3 | Can’t handle user input                                              | Can handle user input                                                    |
    | 4 | Good for showing info messages to user                               | Good for showing warning/info type messages to user that needs attention |
    +---+----------------------------------------------------------------------+--------------------------------------------------------------------------+
    

提交回复
热议问题