这个视图原始框架地址: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" />

效果:

设置为不可用状态:

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 控件学习的更多相关文章

  1. IOS学习笔记(四)之UITextField和UITextView控件学习

    IOS学习笔记(四)之UITextField和UITextView控件学习(博客地址:http://blog.csdn.net/developer_jiangqq) Author:hmjiangqq ...

  2. DevExpress控件学习总结(转)

    DevExpress控件学习总结   1.Navigation & Layout 1.1 Bar Manager 如果想在窗体或用户控件(user control)上添加工具条(bars)或弹 ...

  3. Android Material Design控件学习(三)——使用TextInputLayout实现酷市场登录效果

    前言 前两次,我们学习了 Android Material Design控件学习(一)--TabLayout的用法 Android Material Design控件学习(二)--Navigation ...

  4. wxPython控件学习之wx.grid.Grid 表格控件

    wxPython控件学习之wx.grid.Grid (包括对GridCellEditor和GridCelRender的扩展,以支持更多的grid cell 样式, 以GridCellColorEdit ...

  5. 转)delphi chrome cef3 控件学习笔记 (二)

    (转)delphi chrome cef3 控件学习笔记 (二) https://blog.csdn.net/risesoft2012/article/details/51260832 原创 2016 ...

  6. PyQt5Day03--程序基本结构之面向对象版本+控件学习

    1.程序基本结构之面向对象版本 (1)开发阶段(自己写好并测试)——设置为模版qto from PyQt5.Qt import * class Window(QWidget): def __init_ ...

  7. dsoframer控件学习小结(打开WORD,EXCEL等文件)

    根据自己对dsoframer控件的学习,想把dsoframer控件进行简单的包装为C#的usercontrol,大体需要作如下:(创建windows的usercontrol的步骤就不再说了...)我们 ...

  8. Android Material Design控件学习(一)——TabLayout的用法

    前言 Google官方在14年Google I/O上推出了全新的设计语言--Material Design.一并推出了一系列实现Material Design效果的控件库--Android Desig ...

  9. 5.Android之image控件学习

    Android中经常用到图片,比如图片浏览.图标等等,今天学习下image控件,image控件主要有ImageButton和ImageView两种. (1)ImageButton 在布局文件增加: & ...

随机推荐

  1. hudson

    来源: hudson入门与实战 http://www.360doc.com/content/15/0304/22/12144668_452603921.shtml Hudson安装配置.部署应用及分析 ...

  2. ios压缩图片

    /** *  压缩图片到指定文件大小 * *  @param image 目标图片 *  @param size  目标大小(最大值) * *  @return 返回的图片文件 */ - (NSDat ...

  3. C#中几种数据库的大数据批量插入

    C#语言中对SqlServer.Oracle.SQLite和MySql中的数据批量插入是支持的,不过Oracle需要使用Orace.DataAccess驱动. IProvider里有一个用于实现批量插 ...

  4. html各元素中的区别

    HTML中DIV与SPAN的区别 html的div和span, 经常会用到, 尤其是前者. 1. div是块级元素, 实际上就是一个区域, 主要用于容纳其他标签. 默认的display属性是block ...

  5. 《JavaScript高级程序设计》读书笔记 ---语句

    do-while语句do-while 语句是一种后测试循环语句,即只有在循环体中的代码执行之后,才会测试出口条件.换句话说,在对条件表达式求值之前,循环体内的代码至少会被执行一次.以下是do-whil ...

  6. python2.7学习记录之四

    1.从raw_input()读取的内容永远以字符串的形式返回,把字符串和整数比较就不会得到期待的结果,必须先用int()把字符串转换为我们想要的整型 2.list增加元素 为 append() 3.d ...

  7. VBS控制鼠标移动和点击(附源代码下载)

    森思:想用vbs来控制鼠标的移动和点击,虽然按键精灵可以做到,但做这么简单的事情不想启动那么大一个程序,所以自己用VC写了一个小程序,可以让VBS来控制鼠标移动和点击. 用法: 移动鼠标到桌面坐标20 ...

  8. JS操作select标签

    主要利用这个来实现省市区三级联动的 我利用的是ajax,每一次onchange事件都改变相对应的select中的option,数据全是ajax请求服务器查询数据库而来的,效果还可以,在本地测试的时候速 ...

  9. CF 508D Tanya and Password(无向图+输出欧拉路)

    ( ̄▽ ̄)" //不知道为什么,用scanf输入char数组的话,字符获取失效 //于是改用cin>>string,就可以了 //这题字符的处理比较麻烦,输入之后转成数字,用到函 ...

  10. MQL5 获取最后一单 利润

    ///x 最后几单 double getLastProfit(int x) { HistorySelect(,TimeCurrent()); double profit ; long ticket ; ...