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
场景:父组件向子组件传递数据,子组件去试图改变父组件数据的时候. 解决:子组件通过事件向父组件传递信息,让父组件来完成数据的更改. 比如:我的父组件是普通页面,子组件是弹窗的登录界面,父组件传递的数据 ...
随机推荐
- action参数绑定
thinkPHP支持操作方法的参数绑定功能 action参数通过直接绑定URL中的变量作为操作方法的参数,可以简化方法的定义甚至路由的简析. 原理是把URL的中参数(不包括模块,控制器和操作名)和控制 ...
- Light OJ 1008
找规律. 首先令n=sqrt(s),上取整.讨论当n为偶数时,若n*n-s<n则x=n,y=n*n-s+1否则x=-n*n+2*n+s-1,y=n;如果n为奇数,交换x,y即可,对称的. Sam ...
- 转:Loadrunner——Simulate a new user on each iteration设置
最近在与大家的讨论中发现了LoadRunner的很多问题,出于解决问题的出发点,我也就相关自己不理解的问题在Google中搜索了一番,并通过一些实例也去实际操作了一遍,发现很多问题确实并不是那么难解决 ...
- Redis(1)在windows环境下的安装和测试
初次准备使用redis,一个著名的nosql缓存数据库. 这里是第一天,就简单写一下windows下的安装,遇到的一些问题,然后简单的使用和测试,之后会在代码中使用和测试. 之后还会在生产环境中进行测 ...
- 监控redis进程,如果没有自动重启
监控redis进程,如果没有自动重启 #Time:2016-01-22#Version:1.0 #Author:chh-huang #设置环境变量source /etc/profile#source ...
- Entity Framework 学习初级篇7--基本操作:增加、更新、删除、事务
本节,直接写通过代码来学习.这些基本操作都比较简单,与这些基本操作相关的内容在之前的1至6节基本介绍完毕. l 增加: 方法1:使用AddToXXX(xxx)方法:实例代码如下: ...
- sql视图
什么是视图 大家都知道,我们国家现在“神七”上天了.从美国的月球登月开始,人类上天不再是神话.听说,在美国,你只要出几十万美元,您就可以上一次月球进行太空旅行,所以,我们相信:在不久的将来,上天旅行将 ...
- ERROR CL .exe……错误
这个错误遇见了两次,一次是在装VC时,解决办法见 这个 还有一次是VS2012时,遇见了: error MSB6006: “CL.exe”已退出,代码为 -1073741515. 解决办法:Add t ...
- 理解用requireJs 来实现javascript的模块化加载
这是我看到的一片关于requirejs的初学者的文章,写的不错,下面结合自己的理解记录一下: 原文:http://www.sitepoint.com/understanding-requirejs-f ...
- ajax编程**
ajax 编程 *step1获得 XmlHttpRequest 对象.该对象由浏览器提供,但是该类型并没有标准化.ie 和其它浏览器不同,其它浏览器都支持该类型,而 ie 不支持. function ...