[关闭]
@lovesosoi 2017-10-31T08:20:43.000000Z 字数 726 阅读 1088

11.2.5 TextInputLayout & TextInputEditText


一、TextInputLayout & TextInputEditText 基本介绍

传统的输入框是 EditText ,在 Material Design 中,增加了一种新样式的输入框 TextInputEditText,是继承与EditText,使用方法基本与 EditText 一致, 一般用的时候在外部嵌套一个TextInputLayout 。显示效果如图:

二、属性介绍

  1. TextInputLayout属性
  2. app:hintAnimationEnabled="true"
  3. 设置是否可以使用动画,默认是true
  4. app:hintEnabled="true"
  5. 设置是否可以使用hint属性,默认是true
  6. app:hintTextAppearance="@style/MyStyle"
  7. 设置hint的文本属性,改变hint文字的大小颜色等属性
  8. app:counterEnabled="true"
  9. 设置是否可以开启计数器,默认是false
  10. app:counterOverflowTextAppearance="@style/MyStyle2"
  11. 设置计算器越位后的文字颜色和大小
  12. app:counterTextAppearance="@style/MyStyle"
  13. 设置正常情况下的计数器文字颜色和大小
  14. app:counterMaxLength="11"
  15. 设置计算器的最大字数限制
  16. app:errorEnabled="true"
  17. 是否允许错误提示
  18. app:errorTextAppearance="@style/MyStyle2"
  19. 错误提示的文字大小和颜色
  20. TextInputEditText 属性和 EditText 差不多就不介绍了

三、代码使用

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注