这个视图原始框架地址: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. TFS 2012使用简介

    为什么使用TFS 2012进行源代码管理——TFS 2012使用简介(一)  来源:雪雁 http://www.cnblogs.com/codelove/archive/2013/03/16/2963 ...

  2. CVE-2014-1767 漏洞分析(2015.1)

    CVE-2014-1767 漏洞分析 1. 简介 该漏洞是由于Windows的afd.sys驱动在对系统内存的管理操作中,存在着悬垂指针的问题.在特定情况下攻击者可以通过该悬垂指针造成内存的doubl ...

  3. C中内存分配方式[转载]

    在C 中,内存分成5个区,他们分别是堆.栈.自由存储区.全局/静态存储区和常量存储区. 一.简介: 1.栈,就是那些由编译器在需要的时候分配,在无需的时候自动清除的变量的存储区.里面的变量通常是局部变 ...

  4. iOS不可变数组的所有操作

    #pragma mark 创建数组 //1.通过对象方法创建数组 NSArray * array = [[NSArray alloc]initWithObjects:@"One", ...

  5. 《JS权威指南学习总结--1.2客户端JS》

    1.2客户端JS --本节讲述客户端JS部分各章节的讲述内容 一.第十三章讲述JS代码通过<script>标签来嵌入到HTML文件中. 二.第十四章讲解WEB浏览器脚本技术,并涵盖客户端J ...

  6. delete、truncate与drop的区别

    转自:SQL truncate .delete与drop区别 相同点: 1.truncate和不带where子句的delete.以及drop都会删除表内的数据. 2.drop.truncate都是DD ...

  7. ldap基本命令

    前端数据如下: ### frontend.ldif ### dn: dc=ldap,dc=example,dc=com objectclass: top objectclass: dcObject o ...

  8. OpenCV成长之路:图像直方图

    http://ronny.blog.51cto.com/8801997/1394115 2014-04-11 13:47:27 标签:opencv 直方图 统计表 原创作品,允许转载,转载时请务必以超 ...

  9. JDK和JRE的区别

    JDK(Java Development Kit)是针对Java开发员的产品,是整个Java的核心,包括了Java运行环境JRE.Java工具和Java基础类库.Java Runtime Enviro ...

  10. Primes on Interval

    AC代码: #include <cstdio> #include <cstring> #include <iostream> #include <algori ...