MaterialEditText 控件学习
这个视图原始框架地址:https://github.com/rengwuxian/MaterialEditText
指导手册:http://www.rengwuxian.com/post/materialedittext#content
接下来是我学习和总结的时候了:
1,没配置相关属性参数:
<com.yh.materialeditlibrary.MaterialEditText
android:id="@+id/basicEt"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="Basic" />
效果:
M_DXC4}}LA76}Z40UT@[9.png)
设置为不可用状态:
enableBt.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
basicEt.setEnabled(!basicEt.isEnabled());
enableBt.setText(basicEt.isEnabled() ? "DISABLE" : "ENABLE");
}
});
效果:
1 BaseColor
文档里面是这么说的:
Base Color 被用作背景线的颜色、主字体的颜色(透明度被重置为87%)和提示字体的颜色(透明度被重置为26%)。你可以使用app:baseColor
(xml) 或者 setBaseColor()
(java) 来指定 Base Color 。Base Color 的默认值为纯黑
修改为红色:
<com.yh.materialeditlibrary.MaterialEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Custom Base Color"
app:baseColor="@color/red" />
效果:
2 Primary Color
自定义Primary Color
Primary Color 被用作激活状态的输入框背景色、高亮的Floating Label色和底部省略号的颜色。你可以使用 app:primaryColor
(xml) 或者 setPrimaryColor()
(java) 来指定 Primary Color。如果没有设置Primary Color,默认将使用 Base Color 来替代
也就是获取焦点状态时的底部颜色
默认颜色为红色,点击后显示为绿色的底.
<com.yh.materialeditlibrary.MaterialEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Custom Primary Color"
app:baseColor="@color/red"
app:primaryColor="@color/green" />
没点击状态:
点击后:
3 Floating Label
Floating Label 有三种模式: none
, normal
, highlight
。 你可以使用 app:floatingLabel
(xml) 或者setFloatingLabel()
(java) 来设置 Floating Label 的模式
从效果中明显看出是在EditText上面显示的问题的高亮程度,none,压根不显示,normal 默认的亮度,hightlight 高亮显示
none:
xml:
<com.yh.materialeditlibrary.MaterialEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Floating Label"
app:floatingLabel="none" />
<com.yh.materialeditlibrary.MaterialEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Highlight Floating Label"
app:floatingLabel="normal" />
<com.yh.materialeditlibrary.MaterialEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Highlight Floating Label"
app:floatingLabel="highlight" />
4 singleLineEllipsis
当设置显示底部省略号后,控件会在文字向左滚动时在底部左侧显示一个三个点的省略号,点击省略号将自动把光标置于字符串的开始处。你可以通过 app:singleLineEllipsis=true
(xml) 或者 setSingleLineEllipsis()
(java) 来设置它。这个属性将自动设置android:singleLine
为 true
首先这个控件在不选中是不显示...的,而且滑动到最左侧,...小时,滑向右侧,...出现
<com.yh.materialeditlibrary.MaterialEditText
android:id="@+id/singleLineEllipsisEt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Single Line Ellipsis"
android:text="soyoungboy is beautiful ,so cool ,so nice ,so smart"
app:singleLineEllipsis="true" />
效果:
5 maxCharacters
设置字符数限制后,控件右下角会显示已输入字符数和最大字符数的角标,并在超过限制后显示警告色(默认为红色)。 你可以通过app:maxCharacters
(xml) 或者 setMaxCharacters()
(java) 来设置字符数,通过 app:errorColor
或者 setErrorColor()
(java) 来自定义警告色
app:maxCharacters="10" 设置最长文字长度10个
没超过10个字:
当超过10个字时,效果如下:6 自定义 error color
自定义警告颜色:
比如设置超过10个字时,颜色为绿色
<com.yh.materialeditlibrary.MaterialEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:errorColor="@color/green"
app:maxCharacters="10" />
MaterialEditText 控件学习的更多相关文章
- IOS学习笔记(四)之UITextField和UITextView控件学习
IOS学习笔记(四)之UITextField和UITextView控件学习(博客地址:http://blog.csdn.net/developer_jiangqq) Author:hmjiangqq ...
- DevExpress控件学习总结(转)
DevExpress控件学习总结 1.Navigation & Layout 1.1 Bar Manager 如果想在窗体或用户控件(user control)上添加工具条(bars)或弹 ...
- Android Material Design控件学习(三)——使用TextInputLayout实现酷市场登录效果
前言 前两次,我们学习了 Android Material Design控件学习(一)--TabLayout的用法 Android Material Design控件学习(二)--Navigation ...
- wxPython控件学习之wx.grid.Grid 表格控件
wxPython控件学习之wx.grid.Grid (包括对GridCellEditor和GridCelRender的扩展,以支持更多的grid cell 样式, 以GridCellColorEdit ...
- 转)delphi chrome cef3 控件学习笔记 (二)
(转)delphi chrome cef3 控件学习笔记 (二) https://blog.csdn.net/risesoft2012/article/details/51260832 原创 2016 ...
- PyQt5Day03--程序基本结构之面向对象版本+控件学习
1.程序基本结构之面向对象版本 (1)开发阶段(自己写好并测试)——设置为模版qto from PyQt5.Qt import * class Window(QWidget): def __init_ ...
- dsoframer控件学习小结(打开WORD,EXCEL等文件)
根据自己对dsoframer控件的学习,想把dsoframer控件进行简单的包装为C#的usercontrol,大体需要作如下:(创建windows的usercontrol的步骤就不再说了...)我们 ...
- Android Material Design控件学习(一)——TabLayout的用法
前言 Google官方在14年Google I/O上推出了全新的设计语言--Material Design.一并推出了一系列实现Material Design效果的控件库--Android Desig ...
- 5.Android之image控件学习
Android中经常用到图片,比如图片浏览.图标等等,今天学习下image控件,image控件主要有ImageButton和ImageView两种. (1)ImageButton 在布局文件增加: & ...
随机推荐
- 手动编译生成apk
转载一篇介绍如何去手动编译生成apk的文章: http://jojol-zhou.iteye.com/blog/729254
- 关于UIFont和计算字符串的高度和宽度
转自:http://i.cnblogs.com/EditPosts.aspx?opt=1 1.创建方法:+ fontWithName:size:- fontWithSize:2.创建系统字体:+ sy ...
- pgadmin3 新建服务器出现错误 Peer authentication failed for user "postgres" 的解决办法
转自:http://blog.csdn.net/tingyuanss/article/details/43763899 用pgadmin3 新建服务器出现错误 Peer authentication ...
- 二十一、oracle pl/sql分类一 存储过程
存储过程用于执行特定的操作,当建立存储过程时,既可以指定输入参数(in),也可以指定输出参数(out),通过在过程中使用输入参数,可以将数据传递到执行部分:通过使用输出参数,可以将执行部分的数据传递到 ...
- VoIP的话音质量测量方法
严重的呼叫质量和性能管理问题会影响VoIP (Voice over IP)系统的运作.网络管理员等人需要理解基本的呼叫质量测量技术才能很好地监测.管理和诊断在VoIP中出现的这些问题.本文介绍了常用的 ...
- mysql出现Can't connect to MySQL server on 'localhost' (10061)的解决方法
网上搜索的一: 今天把mysql数据库拷贝到另外一台机上,结果连不上,报“Can't connect to MySQL server on 'localhost' (10061)“错误 到网上sear ...
- IT人为什么难以拿到高薪?【转帖】
最近在论坛里看到很多人发牢骚,说薪水少,可在我看来,你们这样的人拿得到高薪才怪! 我先问一句:这里有多少人是本科的?有多少人是正规本科的(不算自考,成考和专升本)?有多少人是有学位的?有多少有学位的是 ...
- TCP/IP,http,socket,长连接,短连接——小结。
来源:http://blog.chinaunix.net/uid-9622484-id-3392992.html TCP/IP是什么? TCP/IP是个协议组,可分为三个层次:网络层.传输层和应用层. ...
- 关于Adobe CC 系列软件反复弹出 Adobe 软件许可问题
最近装了falsh cc2014 版本,并结合网络提供资源破解(可参考:http://www.cnblogs.com/-yan/p/4450196.html) 但是,使用超过二十四小时后(时间为估计值 ...
- 安卓无法生成R文件原因
原因个人总结出来: 清单文件报错,则无法生成R文件 gen和bin目录可以删除