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
场景:父组件向子组件传递数据,子组件去试图改变父组件数据的时候. 解决:子组件通过事件向父组件传递信息,让父组件来完成数据的更改. 比如:我的父组件是普通页面,子组件是弹窗的登录界面,父组件传递的数据 ...
随机推荐
- javascript语句语义大全(1)
1. <script></script> javascript标签对,所有javascript内容都会写在这个里面 2. var a=0; var a; 变量的声明,上面的是声 ...
- PL/SQL Developer StringBuffer 专用复制
;PL/SQL Developer SpecialCopy definition;<LINE_1> for first line;<LINE_*> for all other ...
- POJ 1236 Network of Schools(tarjan算法 + LCA)
这个题目网上有很多答案,代码也很像,不排除我的.大家的思路应该都是taijan求出割边,然后找两个点的LCA(最近公共祖先),这两个点和LCA以及其他点构成了一个环,我们判断这个环上的割边有几条,我们 ...
- HDU 3861 The King’s Problem(tarjan连通图与二分图最小路径覆盖)
题意:给我们一个图,问我们最少能把这个图分成几部分,使得每部分内的任意两点都能至少保证单向连通. 思路:使用tarjan算法求强连通分量然后进行缩点,形成一个新图,易知新图中的每个点内部的内部点都能保 ...
- 如何用好 Google 搜索引擎?
1.双引号 把搜索词放在双引号中,代表完全匹配搜索,也就是说搜索结果返回的页面包含双引号中出现的所有的词,连顺序也必须完全匹配.bd和Google 都支持这个指令.例如搜索: “seo方法图片” 2. ...
- JavaScript(四)---- 函数
函数主要用来封装具体的功能代码. 函数是由这样的方式进行声明的:关键字 function.函数名.一组参数,以及置于括号中的待执行代码. 格式: function 函数名(形参列表){ ...
- 激活OFFICE2010时,提示choice.exe不是有效的win32程序
我在安装office2010破解版时,提示choice.exe不是有效的win32应用程序 删除choice.exe再激活,按提示找到目录删掉这个文件,需要设置显示隐藏文件夹
- Sphinx配置过程
http://www.oschina.net/question/84274_11938 http://www.ibm.com/developerworks/library/os-php-sphinxs ...
- SD卡的SPI模式的初始化顺序(转)
为了使SD卡初始化进入SPI模式,我们需要使用的命令有3个:CMD0,ACMD41,CMD55(使用ACMD类的指令前应先发CMD55,CMD55起到一个切换到ACMD类命令的作用). 为什么在使用C ...
- Sasha and Array
Sasha and Array time limit per test 5 seconds memory limit per test 256 megabytes input standard inp ...