1. 吐司:
它是一个 Android UI 组件,用于显示不需要任何用户操作的消息或通知。它与显示它的活动无关,并在设置的持续时间后自动消失。
2. 小吃店:
它是 Android Material Design UI 组件。它用于向用户显示需要一些用户操作的弹出消息。它可以在设定的时间后自动消失,也可以被用户解除。
Toast 和 SnackBar 的区别:
S. No. | Toast | SnackBar |
---|---|---|
1. | Toast is Android UI component present since API 1 | It was later introduced with material design in API 23 |
2. | It is not linked to an activity. | It is linked with parent activity. |
3. | User input can’t be taken. | User input can be taken. |
4. | It can’t be shown indefinitely | It can be shown for indefinite duration |
5. | It can’t be closed by user action | It can be closed by user action. |
6. | It is mostly used to show feedback message | It is used show message that need user action |
7. | It is used for showing info messages to user | It is used for showing warning/info type messages to user that needs attention. |
8. | It can’t be closed by swiping. | It can be closed by swipe. |