FAB、TextInputLayout及Snackbar笔记
FloatingActionButton
由于FloatingActionButton是重写ImageView的,所有FloatingActionButton拥有ImageView的一切属性.
控制FloatingActionButton的大小,背景颜色,阴影的深度等:
- app:fabSize 有两种赋值分别是 “mini” 和 “normal”,默认是“normal”.
- app:backgroundTint 默认的背景颜色是Theme主题中的
- app:elevation 阴影面积,dp为单位,越大阴影面积越大
注意:不能通过 android:background 属性来改变背景颜色,只能通过app:backgroundTint,因为FAB是继承自ImageView的。
TextInputLayout
里面需要放一个EidtText
<android.support.design.widget.TextInputLayout
android:id="@+id/textInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"> <EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</android.support.design.widget.TextInputLayout>
final TextInputLayout inputLayout = findView(R.id.textInput);
inputLayout.setHint("input:");
EditText editText = inputLayout.getEditText();
editText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
} @Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if (s.length()>4){
inputLayout.setErrorEnabled(true);//设置是否显示错误信息
inputLayout.setError("error text");
}else{
inputLayout.setErrorEnabled(false);
}
} @Override
public void afterTextChanged(Editable s) {
}
});
这个不知道为什么,我这的错误信息只会显示一次,删掉,重新写就不会出现了,OTZ……<待解决……
Snackbar
final Snackbar snackbar = Snackbar.make(view,"text",Snackbar.LENGTH_LONG);
snackbar.setActionTextColor(getResources().getColor(R.color.colorPrimary));
snackbar.setAction("undo", new View.OnClickListener() {
@Override
public void onClick(View view) {
snackbar.dismiss();
}
}).show();
参考文章:
http://blog.csdn.net/feiduclear_up/article/details/46500865
http://blog.csdn.net/u010687392/article/details/46876679
FAB、TextInputLayout及Snackbar笔记的更多相关文章
- 【转】Android M新控件之FloatingActionButton,TextInputLayout,Snackbar,TabLayout的使用
Android M新控件之FloatingActionButton,TextInputLayout,Snackbar,TabLayout的使用 分类: Android UI2015-06-15 16: ...
- Material Design之TextInputLayout、Snackbar的使用
这两个控件也是Google在2015 I/O大会上公布的Design Library包下的控件,使用比較简单,就放在一起讲了,但有的地方也是须要特别注意一下. TextInputLayout Text ...
- 【转】Android开发笔记(序)写在前面的目录
原文:http://blog.csdn.net/aqi00/article/details/50012511 知识点分类 一方面写写自己走过的弯路掉进去的坑,避免以后再犯:另一方面希望通过分享自己的经 ...
- 【转】Android M新控件之AppBarLayout,NavigationView,CoordinatorLayout,CollapsingToolbarLayout的使用
Android M新控件之AppBarLayout,NavigationView,CoordinatorLayout,CollapsingToolbarLayout的使用 分类: Android UI ...
- Material Design with the Android Design Support Library
Material Design with the Android Design Support Library 原文http://www.sitepoint.com/material-design-a ...
- 使用 CoordinatorLayout 实现复杂联动效果
GitHub 地址已更新: unixzii / android-FancyBehaviorDemo CoordinatorLayout 是 Google 在 Design Support 包中提供的一 ...
- 竞品调研时发现的Android新设计特性
先share两篇技术层面的文章: Android M新控件之FloatingActionButton,TextInputLayout,Snackbar,TabLayout的使用:http://blog ...
- Android新版本特性以及注意事项
版权声明:本文为HaiyuKing原创文章,转载请注明出处! 概述 了解新版本的特性还是很有必要的,为什么这么讲呢?因为可以从应用市场对发布应用的目标API版本(targetSdkVersion值)的 ...
- Vue 报错[Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders
场景:父组件向子组件传递数据,子组件去试图改变父组件数据的时候. 解决:子组件通过事件向父组件传递信息,让父组件来完成数据的更改. 比如:我的父组件是普通页面,子组件是弹窗的登录界面,父组件传递的数据 ...
随机推荐
- 九宫格问题 A*
八数码问题 一.八数码问题八数码问题也称为九宫问题.在3×3的棋盘,摆有八个棋子,每个棋子上标有1至8的某一数字,不同棋子上标的数字不相同.棋盘上还有一个空格,与空格相邻的棋子可以移到空格中.要求解决 ...
- Node.js学习 - Route
Node.js 路由 URL解析,需要url和querystring两个模块url.parse(string).query | url.parse(string).pathname | | | | | ...
- elk集成安装配置
三台虚拟机 193,194,195 本机 78 流程 pythonserver -> nginx -> logstash_shipper->kafka->logstash_in ...
- 用SqlBulkCopy批量插入数据 遇到的错误
在将txt文本格式的数据导入到数据库中时候,使用的是SqlBulkCopy.但是出现了多处错误,在网上查到得资料如下: 错误一:来自数据源的 String 类型的给定值不能转换为指定目标列的类型 nv ...
- 关于MyEclipse不停报错multiple problems have occurred 或者是内存不足 的解决办法
这是因为 worksapace与svn代码不一样,要更新! 一更新就好了,困扰死我了,卧槽,搞了2个小时,难怪svn一提交就卡死人,原来还就是svn的问题,更新一下就行.
- ural1067 Disk Tree
Disk Tree Time limit: 2.0 secondMemory limit: 64 MB Hacker Bill has accidentally lost all the inform ...
- HDU - 2680 最短路 spfa 模板
题目链接http://acm.hdu.edu.cn/showproblem.php?pid=2680 题目大意,就是一个人可以从多个起点开始出发,看到终点的最短路是多少..只有可以运用和hdu2066 ...
- adb not responding. if you'd like to
在安装genymotion后启动工程报此错误. 解决方案:把其他虚拟机删掉,然后用genymotion新建一个,启动工程OK.
- jQuery之call()方法的使用
最近在做项目时候,写了几行关于DOM操作的代码,在方法中使用了this,在后期重构的时候,想将这段分离出来做成一个方法. 最开始想的很简单,就直接分离出来使用方法名称调用即可. 但是实际操作的时候没有 ...
- chromium high cpu usage
ctrl + esc 列出哪个进程占用了cpu,可以杀掉. --purge-memory-button可以在上边弹出的窗口上显示一个按钮,据说能释放内存.