TextInputEditText
是在Design包中MD风格的EditText。
- 样式调整
<style name="InputStyle">
<!-- 底部线 默认颜色 -->
<item name="colorControlNormal">@android:color/white</item>
<!-- 底部线 EditText激活时颜色 -->
<item name="colorControlActivated">@android:color/white</item>
<!-- 设置光标 -->
<item name="android:textCursorDrawable">@drawable/line</item>
</style>
android:textCursorDrawable为@null时光标颜色与textColor相同,但是目测宽度只有1dp左右,太细了,所以最终还是选择了自定义光标
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@android:color/black" />
<size android:width="2dip" />
</shape>
- 取消底部线
如果要取消TextInputEditText底部线,在EditText中我们设置background=@null,但是TextInputEditText不同,我们需要将TextInputLayout和TextInputEdit的backgound都设置为@null
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null">
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:hint="请输入手机号码"
android:padding="8dp"/>
</android.support.design.widget.TextInputLayout>
网友评论