android:imeOptions属性详解以及无效处理

(1)actionUnspecified未指定,对应常量EditorInfo.IME_ACTION_UNSPECIFIED效果:

(2)actionNone 没有动作,对应常量EditorInfo.IME_ACTION_NONE效果:
(3)actionGo去往,对应常量EditorInfo.IME_ACTION_GO 效果:
(4)actionSearch 搜索,对应常量EditorInfo.IME_ACTION_SEARCH效果:
(5)actionSend 发送,对应常量EditorInfo.IME_ACTION_SEND效果:
(6)actionNext 下一个,对应常量EditorInfo.IME_ACTION_NEXT效果:
(7)actionDone 完成,对应常量EditorInfo.IME_ACTION_DONE效果:

android:imeOptions=”flagNoExtractUi” //使软键盘不全屏显示,只占用一部分屏幕 同时,
这个属性还能控件软键盘右下角按键的显示内容,默认情况下为回车键
android:imeOptions=”actionNone” //输入框右侧不带任何提示
android:imeOptions=”actionGo” //右下角按键内容为’开始’
android:imeOptions=”actionSearch” //右下角按键为放大镜图片,搜索
android:imeOptions=”actionSend” //右下角按键内容为’发送’
android:imeOptions=”actionNext” //右下角按键内容为’下一步’ 或者下一项
android:imeOptions=”actionDone” //右下角按键内容为’完成’

注意:如果设置了 键盘没有变化 那么需要单独加一些其他的属性 配合使用

xml中 属性设置:

1 将singleLine设置为true

2 将inputType设置为text

java代码设置
editText.setInputType(EditorInfo.TYPE_CLASS_TEXT);
editText.setImeOptions(EditorInfo.IME_ACTION_SEARCH);

猜你喜欢

转载自blog.csdn.net/waa_0618/article/details/75093518