我们现在在做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. PatentTips - Fair scalable reader-writer mutual exclusion

    BACKGROUND The present invention relates generally to multithreaded programming and, more specifical ...

  2. angular的又一本好书

    MANNING出的<ANGULAR.JS IN ACTION>. 比上本看完的书<ANGULAR ESSENTIAL>多了一些有全局性的东东. 八个关键概念:MODULE,CO ...

  3. ASP.NET MVC 源码分析(一)

    ASP.NET MVC 源码分析(一) 直接上图: 我们先来看Core的设计: 从项目结构来看,asp.net.mvc.core有以下目录: ActionConstraints:action限制相关 ...

  4. MySQL终端(Terminal)命令基本操作(转)

    注意:MySQL数据库命令不区分大小写.但在MAC的终端,如果你想使用tab自动补全命令,那么你就必须使用大写,这样MAC的终端才会帮你补全命令,否则你按N遍tab都不会有响应. 1.数据库(data ...

  5. oracle latch

    (转载 : http://www.dbtan.com/2010/05/latch-free.html) Latch Free(闩锁释放):Latch Free通常被称为闩锁释放,这个名称常常引起误解, ...

  6. ural 1468

    写了好久,不知道为什么不过,也不清楚到底卡在哪里... 只好看别人的代码,感觉除了HASH不一样外,倒没什么特别之处.同时参考那论文写的.. http://blog.csdn.net/jyysc201 ...

  7. IE新发现

    近期用thinkphp写的小程序在IE上測试的时候偶然发现原来IE不兼容的不止是样式啊!!! 震惊哭了~ 在火狐上面嗖嗖的一点bug也没有,在IE上面跟死水一样.. .. 那么问题来了:我的问题是出如 ...

  8. Sublime text 神器小记

    曾经一直使用的都是Editplus,一直感觉都是非常不错的. 可是近期接触到sublime text,我就fall in love with it. Sublime 的意思是"顶峰,高尚,非 ...

  9. Building Maintainable Software-java篇之Couple Architecture Components Loosely

    Building Maintainable Software-java篇之Couple Architecture Components Loosely There are two ways of co ...

  10. 二分查找(c &amp; c++)

    typedef int ElemType; C版本号 [递归版本号] int binSearch2(ElemType List[] ,int x,int head,int tail){ //递归版本号 ...