在android开发过程中,涉及到EditText的几个小知识点:
<1>改变光标颜色
光标显示为绿色
使用到的属性为
android:textCursorDrawable="@drawable/shape_textcursor"
shape_textcursor.xml其实是一个shape
shape_textcursor.xml
<2>改变下划线
边框样式的EditText
使用到的属性为
android:background="@drawable/shape_et"
android:background="@null"
同样,shape_et.xml的代码:
shape_et.xml
<3>修改选中时的光标样式
选中时显示的样式
使用到的属性
android:textSelectHandleLeft="@mipmap/ic_launcher"
android:textSelectHandleRight="@mipmap/ic_launcher"
(注:为了省事,直接使用了ic_launcher)
<4>修改软键盘右下角确定键的样式
使用到的属性:
android:imeOptions="actionNext"
android:imeActionLabel="下一项"
<5>隐藏软键盘的两个方法
1.设置edittext属性,设置焦点在其他控件上:
android:focusable="false"
android:focusableInTouchMode="false"
2.在清单文件中设置:
<activity
android:name=".MainActivity"
android:windowSoftInputMode="stateHidden|stateAlwaysHidden" >
</activity>
或者在代码中:
getWindow().setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN)
以上5个小知识点不知道大家在开发中是否使用到了,如有错误的地方欢迎大神指正.