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 ...
随机推荐
- js的this几种用法
1.普通的函数调用 此时指的是全局对象 function aaa(){ this.x=1;}aaa();alert(x) 2.对象内的方法this调用 此时指的是上一级对象 var aaa={ zz: ...
- 20160125--Spring
package com.hanqi; import java.util.*; import com.hanqi.User; public class HelloWorld { public Hello ...
- 20151204--JDBC
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding= ...
- Linux_常用命令
文件搜索 -find -locate -grep 字符串搜索 -grep 过滤 -grep/find/xargs/ 编辑 -sed 待续....
- leetcode Remove Element python
class Solution(object): def removeElement(self, nums, val): """ :type nums: List[int] ...
- Swift 断言
assert(条件,"输出信息"); 如: let age=-1; assert(age>=0,"age要大于0");
- php数组array,知道键名如何提取键值
如果是知道键值,需要查找键名,直接使用array_search()即可.现在反过来,如何操作? (1)array_walk_recursive()加自定义函数查找 $arr=array( 'n ...
- how to install git 1.8 rpm
git版本在低于1.8之前,对于私有项目会出现401的pull失败错误,只能通过升级git版本来解决 It appears that git18 is no longer available from ...
- codeforces 659F . Polycarp and Hay 搜索
题目链接 遍历每个点, 如果这个点的值能被k整除并且k/a[i][j]后小于等于n*m, 那么就对这个点进行搜索. 将这个点加入队列, 将周围的所有大于等于这个点的值的点也加入队列. 不断重复, 直到 ...
- Stream与byte转换
将 Stream 转成 byte[] /// <summary> /// 将 Stream 转成 byte[] /// </summary> public byte[] Str ...