您的位置:首页 > 移动开发

学习笔记 AppCompatEditText

2017-01-17 11:46 190 查看
from : http://blog.csdn.net/starlit53/article/details/50637889
android.support.v7.widget.AppCompatEditText
只有浮动标签
style中添加
[html] view plaincopy</pre><pre name="code" class="html">   <style name="txt_lab" parent="TextAppearance.AppCompat">          <!-- 默认状态提示颜色和字体-->          <item name="android:textColorHint">#8c8c8c</item>          <item name="android:textSize">14sp</item>          <!-- 下面可以根据需要设置,如果没有将默认使用默认theme的颜色 -->          <!-- Label标签的颜色 -->          <item name="colorAccent">#c6174e</item>          <!-- 默认状态状态设置底线颜色 -->          <item name="colorControlNormal">#3F51b5</item>          <!-- 选择的底线颜色 -->          <item name="colorControlActivated">#c6174e</item>      </style>  
XML
[html] view plaincopy<android.support.design.widget.TextInputLayout      android:id="@+id/til_password"      android:layout_width="match_parent"      android:layout_height="wrap_content"      android:theme="@style/txt_lab">      <android.support.v7.widget.AppCompatEditText          android:id="@+id/acet_password"          android:layout_width="match_parent"          android:layout_height="wrap_content"          android:hint="@string/txt_password"          />  </android.support.design.widget.TextInputLayout>  
有错误提示的
style中添加
[html] view plaincopy<style name="txt_lab_msg" parent="@android:style/TextAppearance">      <item name="android:textColor">#c6174e</item>      <item name="android:textSize">12sp</item>  </style>  
Xml中添加app:errorEnabled="true"
代码设置  til_Password.setError("请输入密码!");
XML
[java] view plaincopy<android.support.design.widget.TextInputLayout              android:id="@+id/til_password"              android:layout_width="match_parent"              android:layout_height="wrap_content"              android:theme="@style/txt_lab"              app:errorEnabled="true"              app:errorTextAppearance="@style/txt_lab_msg"              >                <android.support.v7.widget.AppCompatEditText                  android:id="@+id/acet_password"                  android:layout_width="match_parent"                  android:layout_height="wrap_content"                  android:hint="@string/txt_password"                  />          </android.support.design.widget.TextInputLayout>  
搬运一个比较强大的第三方库
https://github.com/rengwuxian/MaterialEditText
中文API
http://www.rengwuxian.com/post/materialedittext
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: