这个视图原始框架地址: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. javascript动画效果之匀速运动

    html和css写在一起方便看,div通过定位设置为-200隐藏,span也是通过定位定在div靠左的中间 <!DOCTYPE html> <html> <head> ...

  2. NYOJ-71 独木舟上的旅行 (贪心)

    独木舟上的旅行 时间限制:3000 ms  |  内存限制:65535 KB 难度:2   描述 进行一次独木舟的旅行活动,独木舟可以在港口租到,并且之间没有区别.一条独木舟最多只能乘坐两个人,且乘客 ...

  3. 模拟IIC协议时序

    IIC是飞利浦公司开发的两线式串行总线,主要应用在单片机和外围电子器件之间的数据通讯. IIC总线优点是节约总线数,稳定,快速,是目前芯片制造上非常流行的一种总线,大多数单片机已经片内集成了IIC总线 ...

  4. Linux内核协议栈 NAT性能优化之FAST NAT

    各位看官非常对不起,本文是用因为写的,如果多有不便敬请见谅 代码是在商业公司编写的,在商业产品中也不能开源,再次抱歉   This presentation will highlight our ef ...

  5. Webdriver实现对菜单栏的灵活切换功能,附上代码,类似的菜单栏切换可以自己封装

    有时一级菜单下可能会有二级菜单,这时就需要对其下面的元素进行判断,如果使用webdriver原生的方法去获取未知的元素进行判断,显然是不可能的,因为webdriver本身就是基于明确的元素进行定位的, ...

  6. 常用CSS样式 持续更新

    + CSS + a标签 - 去除a标签下划线 a{ text-decoration:none; } - 未被访问状态下的a标签去除下划线 a:link{ text-decoration:none; } ...

  7. hdu_5787_K-wolf Number(数位DP)

    题目链接:hdu_5787_K-wolf Number 题意: 给你一个区间,让你找满足任意k个数位内都没有相同的数字的个数 题解: 因为k不大,就直接将当前pos的前k-1个数传进去就行了 #inc ...

  8. hdu_3063_Play game(数论)

    题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=3063 题意:中文题,说的很清楚,不解释 题解:公式题,具体看代码 #include<stdio. ...

  9. 确定当前Python环境中的site-packages目录位置

    引入“搜索路径”这个概念是因为在使用import语句时,当解释器遇到import语句,如果模块在当前的搜索路径就会被导入. 搜索路径是一个解释器会先进行搜索的所有目录的列表. 那么python如何添加 ...

  10. Fatal error: Class ‘mysqli’ not found in解决办法

    在使用[$conn = new \mysqli($servername, $username, $password,$dbname);]连接msql数据库的时候 出现错误:[Fatal error: ...