我们现在在做Android端的输入框时,要具备如下功能:

默认提示
获取焦点时提示上移至输入框顶部
获取焦点时输入框有提示
错误时增加错误提示
直接上图:

默认情况:

获取焦点时:

开始输入文字时:

有错误时:

代码为(只写上图其中一个输入框):

<android.support.design.widget.TextInputLayout
android:id="@+id/til"
app:hintTextAppearance="@style/textInputLayoutHint"
app:errorTextAppearance="@style/textInputLayoutError"
android:textColorHint="@color/color_CED2D9"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<com.test.widget.textinput.TrainEditText
android:layout_marginBottom="-4dp"
app:dropdown_enable="false"
android:importantForAutofill="noExcludeDescendants"
android:id="@+id/edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:ellipsize="end"
android:drawablePadding="5dp"
android:paddingBottom="18dp"
android:imeOptions="actionNext"
android:inputType="text"
android:lines="1"
android:theme="@style/EditTextTheme"
android:textCursorDrawable="@drawable/train_edittext_cursor_color"
android:maxLines="1"
android:textColor="@color/color_train_main_text"
android:textColorHint="@color/color_8592A6"
android:textSize="17dp"
android:visibility="visible"
tools:ignore="UnusedAttribute" />

</com.test.widget.textinput.TrainEditText>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
注意:TrainEditText是封装的TextView
那么接下来逐一介绍一下各个地方字体的颜色设置方法:以“姓氏”这个输入框为

TextInputLayout使用时各个地方的字体颜色的更多相关文章

  1. VC、MFC中设置控件的背景色、标题、字体颜色、字体要注意的地方[转]

    在MFC中设置控件的背景色.字体.字体颜色.标题等属性主要是利用OnCtlColor函数来实现. 如: HBRUSH CAlarm::OnCtlColor(CDC* pDC, CWnd* pWnd, ...

  2. 【SpringMVC】<context:include-filter>和<context:exclude-filter>使用时要注意的地方

    http://jinnianshilongnian.iteye.com/blog/1762632 http://blog.51cto.com/wenshengzhu/1700340 http://ww ...

  3. <context:component-scan>子标签:<context:include-filter>和<context:exclude-filter>使用时要注意的地方

    在Spring MVC中的配置中一般会遇到这两个标签,作为<context:component-scan>的子标签出现. 但在使用时要注意一下几点: 1.在很多配置中一般都会吧Spring ...

  4. c++控制输出的字体颜色

    SetConsoleTextAttribute(参数表).SetConsoleTextAttribute()函数是一个API设置字体颜色和背景色的函数.参数表中使用两个属性(属性之间用,隔开).Get ...

  5. PowerDesigner15使用时的十五个问题

    15个问题列表: No.1:是不是一定要从CDM开始设计,然后在进行PDM的设计? NO.2:工具栏palette不见了,如何把它找出来? NO.3: 如何建立与数据库的关联? NO.4: 域和数据项 ...

  6. UILabletext去掉乱码 控制颜色 行高 自定义大小 。显示不同的字体颜色、字体大小、行间距、首行缩进、下划线等属性(NSMutableAttributedString)

    text去掉乱码 设置不同颜色 行高 自定义大小 #import <Foundation/Foundation.h> @interface TextsForRow : NSObject @ ...

  7. HTML中设置超链接字体 & 字体颜色

    定义链接样式 CSS为一些特殊效果准备了特定的工具,我们称之为“伪类”.其中有几项是我们经常用到的,下面我们就详细介绍一下经常用于定义链接样式的四个伪类,它们分别是: :link :visited : ...

  8. Unity 同一Text文本修改不同的字体大小和字体颜色

    类似Html,在color和size对应的<>str</>中,就能修改str的相关属性, 下面的代码就是把time改为字体颜色为红色,大小为40: 而前面的"Time ...

  9. winform在设置控件enabled=false后,无法更改控件字体颜色的问题

    项目界面设计的时候,发现在设置button的enabled=false后,原本设计的字体颜色跟预设的不一样,查了一些资料后,在网上看到这样一段代码: [System.Runtime.InteropSe ...

随机推荐

  1. java中String类型转换为float类型

    import java.io.*; public class Demo1{ public static void main(String args[]) { String df="12.2& ...

  2. Linux下安装lvs

    lvs已经编译到linux内核中,仅仅须要安装lvs的管理软件ipvsadm就可以 1. 插入光盘.查找设备 [root@chen ~]# ls -l /dev | grep cdrom lrwxrw ...

  3. hibernate之关于一对一单向,双向关联映射

    [hibernate]之关于一对一单向,双向关联映射 首先我们来看,Hibernate官方对于一对一单向关联的解释: 基于外键关联的单向一对一关联和单向多对一关联差点儿是一样的. 唯一的不同就是单向一 ...

  4. Codeforces 510 A.Fox and Snake

    题目链接:http://codeforces.com/contest/510/problem/A A. Fox And Snake time limit per test2 seconds memor ...

  5. 你不知道的JavaScript--Item33 跨域总结与解决的方法

    一.神马是跨域(Cross Domain) 说白点就是post.get的url不是你当前的站点,域名不同.比如在*aaa.com/a.html*里面,表单的提交action是bbb.com/b.htm ...

  6. couchbase的备份与恢复命令

    下面技术应用于最优质的水果的鲜果篮 ./cbbackup http://192.168.1.112:8091 /backups/20140505 -u Administrator -p passwor ...

  7. commons-fileupload上传文件(1)

    近期,写一个上传图片的功能.于是用到commons-fileupload这个组件.提过form提交表单到后台(这里没实用到structs框架).在后台List pl = dfu.parseReques ...

  8. oc51--循环retain

    // main.m // 循环retain #import <Foundation/Foundation.h> #import "Person.h" #import & ...

  9. framebuffer的入门介绍-实现程序分析【转】

    本文转载自:http://blog.csdn.net/liuzijiang1123/article/details/46972723 如想想对lcd屏进行操作(例如在lcd屏幕上画线,或者显示视频数据 ...

  10. 深入浅出时序数据库之预处理篇——批处理和流处理,用户可定制,但目前流行influxdb没有做

    时序数据是一个写多读少的场景,对时序数据库以及数据存储方面做了论述,数据查询和聚合运算同样是时序数据库必不可少的功能之一.如何支持在秒级对上亿数据的查询分组聚合运算成为了时序数据库产品必须要面对的挑战 ...