这个视图原始框架地址: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. 循环移位法和数据拼接法基于led

    功能描述 让led每隔0.5s从两边向中间闪烁,然后在从中间向两边闪烁,不断循环 项目实现 开发板 晶振为50M,那么达到0.5s时计数器count1需要达到24_999_999这么多次数 计数器代码 ...

  2. 获取android源码中遇到的问题

    最近项目相当紧张,回家之后还需要继续研究android源码. 从网上找了一些资料,下载过程中还是遇到了很多问题.这里罗列一下: 1. 下载Repo过程中提示证书问题: curl https://dl- ...

  3. zend guard Optimizer

    zend guard Optimizer PHP5.3+ URL:http://www.zend.com/en/products/guard/downloads Email:test001@test0 ...

  4. java类中为什么设置set和get方法操作属性

    java程序规范中会建议大家尽量将类中的属性私有化,即定义为private变量,通过设置set和get函数来对属性进行操作.一些人存在这样的疑问,为什么不直接将属性设置为public,以后调用属性时直 ...

  5. Bourn Again Shell编程

    shell既是命令解释程序,又是一种高级程序设计语言.shell是解释型语言. bash脚本的建立和运行: 注释行以#开头 #!后面的参数告诉系统执行本文件的程序 执行脚本文件有两种方法: 1.   ...

  6. Hadoop上的中文分词与词频统计实践 (有待学习 http://www.cnblogs.com/jiejue/archive/2012/12/16/2820788.html)

    解决问题的方案 Hadoop上的中文分词与词频统计实践 首先来推荐相关材料:http://xiaoxia.org/2011/12/18/map-reduce-program-of-rmm-word-c ...

  7. mybatis框架源码学习

    转:来自https://my.oschina.net/u/1458864/blog/293659 摘要:初始化mybatis,所有的配置都在configuation 对象中使用mybatis,从sql ...

  8. Android自动测试之Monkey工具

    Monkey工具 前言: 最 近开始研究Android自动化测试方法,对其中的一些工具.方法和框架做了一些简单的整理,其中包括android测试框架.CTS.Monkey. Monkeyrunner. ...

  9. 曾经的ps的图片

  10. 第四十一节,xml处理模块

    XML是实现不同语言或程序之间进行数据交换的协议,XML文件格式如下 读xml文件 <data> <country name="Liechtenstein"> ...