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. lucene 中关于Store.YES 关于Store.NO的解释

    总算搞明白 lucene 中关于Store.YES  关于Store.NO的解释了 一直对Lucene Store.YES不太理解,网上多数的说法是存储字段,NO为不存储. 这样的解释有点郁闷:字面意 ...

  2. Node.js学习 - Function

    Node.js函数和JavaScript类似 function say(word) { console.log(word); } function execute(someFunction, valu ...

  3. 转:透析QTP自动化测试框架SAFFRON

    1.为什么要使用框架? 框架是一组自动化测试的规范.测试脚本的基础代码,以及测试思想.惯例的集合.可用于减少冗余代码.提高代码生产率.提高代码重用性和可维护性.例如QTestWare就是QTP自动化测 ...

  4. linux 命令实现原理

    我们知道有些Linux的命令涉及到一些高效率的算法,在此做出一个积累吧,不是系统的. 1.tail命令打印一个文件的最后num行 2.grep命令从文本中匹配字符串 基于正则表达式的匹配很快. it ...

  5. editplus 正则删换行

    editplus regular expression  ctrl+h 1.替换开始是空行 ^[\t ]*\n 2.替换换行 \n 3.替换包含某字符 .*@126.* excel去重复(或者保留一个 ...

  6. STM32软件复位(基于库文件V3.5)

    源:STM32软件复位(基于库文件V3.5) void SoftReset(void) { __set_FAULTMASK(); // 关闭所有中端 NVIC_SystemReset();// 复位 ...

  7. 黄聪:基于Asp.net的CMS系统We7架设实验(环境WIN7,SQL2005,.NET3.5)(初学者参考贴)

    http://www.cnblogs.com/huangcong/archive/2010/03/30/1700348.html

  8. 运行时设计(Design at Run-time)

    1.定义 传统软件开发必须经历“设计时”和“运行时”两个阶段,运行时设计,顾名思义,就是在软件运行过程中,对软件进行实时设计修改,而无需再次进行编译,用户即可使用. “运行时设计(Design at ...

  9. JSTL select和checkbox的用法

    select的 用法 <select id="roleIds" name="roleIds" multiple="true" back ...

  10. Object.defineproperty实现数据和视图的联动 ------是不是就是 Angular 模型和视图的同步的实现方式???

    参考:http://www.cnblogs.com/oceanxing/p/3938443.html https://developer.mozilla.org/zh-CN/docs/Web/Java ...