Toast的替代者Snackbar
在Android design support library中,SnackBar的使用:
Part 2 – Welcome Snackbar, Goodbye Toast!
Welcome to the second part of the Android design support library tutorial series. In the first part, we talked about Floating action button, its attributes and some of the FAB issues.
Today we will talk about another component “Snackbar”.
Welcome Snackbar, Goodbye Toast!
“Providing lightweight, quick feedback about an operation is a perfect opportunity to use a snackbar.”
Snackbar is another component available in design support library. Using Snackbar, we can show a quick message at the bottom (mostly) of the screen. It’s almost similar to Toast message, but a bit more flexible:
- It automatically disappears after a time out or after user interaction on the screen.
- It can contain an action, which is optional.
- We can dismiss Snackbar by swiping it off the screen.
- It is a context sensitive message and so those messages are part of the UI screen and appears above all other elements on the screen, not like Toast message overlying on a screen.
- Only one snackbar can be displayed at a time.
Snackbar mostly inherits the same methods and attributes as the Toast, example LENGTH_LONG and LENGTH_SHORT attributes for setting the duration.
基本使用用法:
Snackbar.make(rootlayout, "Hello SnackBar!", Snackbar.LENGTH_SHORT)
.setAction("Undo", new View.OnClickListener() {
@Override
public void onClick(View v) {
// Perform anything for the action selected
}
})
.show();
简介:
Snackbar.make(view, message, duration)
.setAction(action message, click listener)
.show();
方法:
make()– To make a Snackbar to display a messagesetAction()– To set an actionshow()– To show a Snackbar
参考: android weekly
http://www.technotalkative.com/part-2-welcome-snackbar-goodbye-toast/
Toast的替代者Snackbar的更多相关文章
- Android开发2:事件处理及实现简单的对话框(Toast,AlertDialog,Snackbar,TextInputLayout的使用)
前言 啦啦啦~又要和大家一起学习Android开发啦,博主心里好激动哒~ 在上篇博文中,我们通过线性布局和基础组件的使用,完成了一个简单的学生课外体育积分电子认证系统的界面,本篇博文,将和大家一起熟悉 ...
- 【转】Android M新控件之FloatingActionButton,TextInputLayout,Snackbar,TabLayout的使用
Android M新控件之FloatingActionButton,TextInputLayout,Snackbar,TabLayout的使用 分类: Android UI2015-06-15 16: ...
- 【Android - MD】之Snackbar的使用
Snackbar 是 Android 5.0 新特性--Material Design 中的一个控件,用来代替 Toast ,Snackbar与Toast的主要区别是:Snackbar可以滑动退出,也 ...
- 安卓高级6 SnackBar
引言 文/李牧羊(简书作者) 原文链接:http://www.jianshu.com/p/2654e6bda3b1 著作权归作者所有,转载请联系作者获得授权,并标注"简书作者". ...
- <Android 基础(十一)> Snackbar
介绍 Snackbars provide lightweight feedback about an operation. They show a brief message at the botto ...
- 【Android - 控件】之MD - Snackbar的使用
Snackbar 是 Android 5.0 新特性——Material Design 中的一个控件,用来代替 Toast ,Snackbar与Toast的主要区别是:Snackbar可以滑动退出,也 ...
- Android Material Design简单使用
吐槽 作为一个 Android developer,没有什么比拿着 UI 设计的一堆 iOS 风格的设计 来做需求更恶心的了,基本所有空间都要照着 iOS 来画一遍,Material Design 辣 ...
- Android Material Design(一)史上最全的材料设计控件大全
主要内容: 本文将要介绍Material design和Support library控件,主要包括TextInputLayout.SwitchCompat.SnackBar.FloatingActi ...
- Codelab for Android Design Support Library used in I/O Rewind Bangkok session
At the moment I believe that there is no any Android Developer who doesn't know about Material Desig ...
随机推荐
- java基础之高级应用
在程序中涉及方法重写的地方使用@override Annotation(只作用于方法)注释可以很好的避免由于重写方法名字过长而造成的程序后期出现的难以调试的错误,特别是程序没有报任何的错误时,而程序的 ...
- ContextMenuStrip 添加在窗体。点击右键不能显示问题解答
ContextMenuStrip控件,系统默认为点击菜单,使用时.需要与你的窗体绑定.如图所示,,form窗体上包括一个contextMenustrip信息.默认状态是无.所以在使用contextMe ...
- Oracle EBS 如何月结、对账[Z]
在Oracle系统处理月结业务时,需要遵循一定的操作顺序.这些业务,牵涉到相应的模块,包括:应付模块.采购模块.库存模块.应收模块.薪资模块.固定资产和总帐模块等 在Oracle系统中,总帐模块处于财 ...
- OC中两个关键字的作用:@property和@synthesize
两个关键字的使用:@property和@synthesize 一.@property关键字这个关键字是OC中能够快速的定义一个属性的方式,而且他可以设置一些值,就可以达到一定的效果,比如引用计数的问题 ...
- JS精粹(二)
这章主要讲语法,DC使用了表示形式语法的巴克斯范式图,这的确比语言来得准确简洁.我只想表达一个问题:表达式与表达式语句的关系.因为其他问题很明白. 从DC的巴科斯范式图上大致可以认为,表达式是比表达式 ...
- 在VS工程中,添加c/c++工程中外部头文件及库
在VS工程中,添加c/c++工程中外部头文件及库的基本步骤: 1.添加工程的头文件目录:工程---属性---配置属性---c/c++---常规---附加包含目录:加上头文件存放目录. 2.添加文件引用 ...
- OpenCV学习(2)--基本数据结构
OpenCV的基本数据结构 CvPoint:表示图像中的点 CvPoint2D32f:二维空间中的点 CvPoint3D32f:三维空间中的点 这些都是结构体,并不是C++语言中的类,所以他们的构造函 ...
- JavaWeb核心编程之(三.1)ServletHello
Servlet简介Java Servlet是和平台无关的服务器端组件,它运行在Servlet容器中. Servlet容器负责Servlet和客户的通信以及调用Servlet方法, 在这里Servlet ...
- 关于表格动态添加行并处理相关表单元素的一些修改----优化for重用(2)
功能介绍: 1.处理了动态行与表单的设值问题 2.添加了行的向上或向下排序 3.添加了可以在当前行的下边或上边增加新行的功能 4.添加了可以单选或勾选多项删除不需要的行的功能 5.添加了新增的行的高亮 ...
- ie6,ie7,ie8 css bug汇总以及兼容解决方法
1:li边距“无故”增加 任何事情都是有原因的,li边距也不例外. 先描述一下具体状况:有些时候li边距会突然增 加很多,值也不固定(只在IE6/IE7有这种现象),让人摸不着头脑,仔细“研究”发现是 ...