snackbar_Android Snackbar示例教程

snackbar

In this tutorial we’ll discuss and implement various forms of Android Snackbar widget in our application.

在本教程中,我们将在应用程序中讨论和实现各种形式的Android Snackbar小部件。

Android Snackbar (Android Snackbar)

Snackbar in android is a new widget introduced with the Material Design library as a replacement of a Toast.

android中的Snackbar是随Material Design库引入的新小部件,可替代Toast。

Android Snackbar is light-weight widget and they are used to show messages in the bottom of the application with swiping enabled. Snackbar android widget may contain an optional action button.

Android Snackbar是轻巧的小部件,用于在启用滑动的情况下在应用程序底部显示消息。 Snackbar android小部件可能包含一个可选的操作按钮。

吐司和小吃店之间的区别 (Difference between Toast and Snackbar)

  1. A Toast messages can be customised and printed anywhere on the screen, but a Snackbar can be only showed in the bottom of the screen

    可以自定义Toast消息并在屏幕上的任何位置打印,但Snackbar只能显示在屏幕底部
  2. A Toast message don’t have action button, but Snackbar may have action button optionally. Though, A Snackbar shouldn’t have more than one action button

    Toast消息没有操作按钮,但是Snackbar可能有操作按钮。 不过,小吃店不应有多个动作按钮
  3. Toast message cannot be off until the time limit finish, but Snackbar can be swiped off before the time limit

    在时间限制完成之前,不能关闭Toast消息,但是可以在时间限制之前关闭Snackbar

Note: Toast message and Snackbar have display length property in common.

注意 :Toast消息和Snackbar具有共同的显示长度属性。

A code snippet to display a basic android Snackbar is shown below.

下面显示了显示基本android Snackbar的代码段。

Snackbar snackbar = Snackbar
        .make(coordinatorLayout, "www.journaldev.com", Snackbar.LENGTH_LONG);
snackbar.show();

In the above snippet make() method accepts three parameters:

在上面的代码段中, make()方法接受三个参数:

  1. coordinatorLayout : It is the root layout of the activity

    coordinatorLayout :它
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值