FloatingActionButton

由于FloatingActionButton是重写ImageView的,所有FloatingActionButton拥有ImageView的一切属性.

控制FloatingActionButton的大小,背景颜色,阴影的深度等:

  1. app:fabSize 有两种赋值分别是 “mini” 和 “normal”,默认是“normal”.
  2. app:backgroundTint 默认的背景颜色是Theme主题中的
  3. 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笔记的更多相关文章

  1. 【转】Android M新控件之FloatingActionButton,TextInputLayout,Snackbar,TabLayout的使用

    Android M新控件之FloatingActionButton,TextInputLayout,Snackbar,TabLayout的使用 分类: Android UI2015-06-15 16: ...

  2. Material Design之TextInputLayout、Snackbar的使用

    这两个控件也是Google在2015 I/O大会上公布的Design Library包下的控件,使用比較简单,就放在一起讲了,但有的地方也是须要特别注意一下. TextInputLayout Text ...

  3. 【转】Android开发笔记(序)写在前面的目录

    原文:http://blog.csdn.net/aqi00/article/details/50012511 知识点分类 一方面写写自己走过的弯路掉进去的坑,避免以后再犯:另一方面希望通过分享自己的经 ...

  4. 【转】Android M新控件之AppBarLayout,NavigationView,CoordinatorLayout,CollapsingToolbarLayout的使用

    Android M新控件之AppBarLayout,NavigationView,CoordinatorLayout,CollapsingToolbarLayout的使用 分类: Android UI ...

  5. Material Design with the Android Design Support Library

    Material Design with the Android Design Support Library 原文http://www.sitepoint.com/material-design-a ...

  6. 使用 CoordinatorLayout 实现复杂联动效果

    GitHub 地址已更新: unixzii / android-FancyBehaviorDemo CoordinatorLayout 是 Google 在 Design Support 包中提供的一 ...

  7. 竞品调研时发现的Android新设计特性

    先share两篇技术层面的文章: Android M新控件之FloatingActionButton,TextInputLayout,Snackbar,TabLayout的使用:http://blog ...

  8. Android新版本特性以及注意事项

    版权声明:本文为HaiyuKing原创文章,转载请注明出处! 概述 了解新版本的特性还是很有必要的,为什么这么讲呢?因为可以从应用市场对发布应用的目标API版本(targetSdkVersion值)的 ...

  9. Vue 报错[Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders

    场景:父组件向子组件传递数据,子组件去试图改变父组件数据的时候. 解决:子组件通过事件向父组件传递信息,让父组件来完成数据的更改. 比如:我的父组件是普通页面,子组件是弹窗的登录界面,父组件传递的数据 ...

随机推荐

  1. UVA - 10048 Audiophobia (Floyd应用)

    题意:求出两点之间所有路径最大权值的最小值. 思路:转变一下Floyd的形式即可: 注意:注意初始化问题,还有UVA奇葩的输出形式. 代码如下: #include<iostream> #i ...

  2. css伪类 伪元素

    之前写了一篇 <详解 CSS 属性 - :before && :after> 的博文,当时自己没分清楚伪元素和伪类,所以在文章内把概念混淆了,庆幸 @riophae 兄指正 ...

  3. ref和out,以及一般方法的引用参数和值参数寻解

    对与ref和out的区别,我相信很多人都知道,这里我简单罗列下: 1.首先ref和out两种类型的参数都是可以将方法内对参数的修改传递到方法外面 2.ref参数需要在传递之前初始化,out不需要,ou ...

  4. Zabbix之配置文件详解

    zabbix的配置文件一般有三种:zabbixserver的配置文件zabbix_server.confzabbixproxy的配置文件zabbix_proxy.confzabbix_agentd的配 ...

  5. Linux 下安装配置 JDK1.7

    目录[-] 1.下载JDK 2.解压安装 3.配置环境变量 4.配置默认JDK(一般情况下这一步都可以省略) 5.测试 1.下载JDK Linux操作系统是:Centos6.5-x64 目前最新的JD ...

  6. Oracle\PLSQL Developer报“动态执行表不可访问,本会话的自动统计被禁止”的解决方案

    现象: 第一次用PLSQL Developer连接数据库,若用sys用户登录并操作则正常,若用普通用户比如haishu登录并创建一个表则报错“动态执行表不可访问,本会话的自动统计被禁止.在执行菜单里你 ...

  7. make[1]: *** [/workopenwrt/trunk/staging_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/stamp/.tools_install_nnnnn] Error 2 make[1]: Leaving directory `/work/openwrt/trunk' make: *** [world]

    主要原因是编译时未连上网,编译时需要下载些插件,连接网后,重启下系统再编译下.

  8. jsp的Get 与 SET的区别

    getParameter:获取前个页面的数据,此方法获取的数据是从前台提交过来的 getAttribute:是获取setAttribute存储的数据 ========================= ...

  9. 设计模式笔记之三:Android DataBinding库(MVVM设计模式)

    本博客转自郭霖公众号:http://mp.weixin.qq.com/s?__biz=MzA5MzI3NjE2MA==&mid=2650236908&idx=1&sn=9e53 ...

  10. Kafka 在行动:7步实现从RDBMS到Hadoop的实时流传输

    原文:https://coyee.com/article/11095-kafka-in-action-7-steps-to-real-time-streaming-from-rdbms-to-hado ...