gistfile1.txt 输入类型属性android 1.5以后添加了软件虚拟键盘的功能,所以在输入提示中将会有对应的软键盘模式android中inputType属性在EditText输入值时启动的虚拟键盘的风格有着重要的作用
输入类型属性
android 1.5以后添加了软件虚拟键盘的功能,所以在输入提示中将会有对应的软键盘模式
android中inputType属性在EditText输入值时启动的虚拟键盘的风格有着重要的作用。这也大大的方便的操作。有时需要虚拟键盘只为字符或只为数字。所以inputType尤为重要。
//文本类型,多为大写、小写和数字符号。
android:inputType="none"
android:inputType="text"
android:inputType="textCapCharacters" 字母大写
android:inputType="textCapWords" 首字母大写
android:inputType="textCapSentences" 仅第一个字母大写
android:inputType="textAutoCorrect" 自动完成
android:inputType="textAutoComplete" 自动完成
android:inputType="textMultiLine" 多行输入
android:inputType="textImeMultiLine" 输入法多行(如果支持)
android:inputType="textNoSuggestions" 不提示
android:inputType="textUri" 网址
android:inputType="textEmailAddress" 电子邮件地址
android:inputType="textEmailSubject" 邮件主题
android:inputType="textShortMessage" 短讯
android:inputType="textLongMessage" 长信息
android:inputType="textPersonName" 人名
android:inputType="textPostalAddress" 地址
android:inputType="textPassword" 密码
android:inputType="textVisiblePassword" 可见密码
android:inputType="textWebEditText" 作为网页表单的文本
android:inputType="textFilter" 文本筛选过滤
android:inputType="textPhonetic" 拼音输入
//数值类型
android:inputType="number" 数字
android:inputType="numberSigned" 带符号数字格式
android:inputType="numberDecimal" 带小数点的浮点格式
android:inputType="phone" 拨号键盘
android:inputType="datetime" 时间日期
android:inputType="date" 日期键盘
android:inputType="time" 时间键盘
android:windowSoftInputMode属性
具体的一些属性:
【A】stateUnspecified:软键盘的状态并没有指定,系统将选择一个合适的状态或依赖于主题的设置
【B】stateUnchanged:当这个activity出现时,软键盘将一直保持在上一个activity里的状态,无论是隐藏还是显示
【C】stateHidden:用户选择activity时,软键盘总是被隐藏
【D】stateAlwaysHidden:当该Activity主窗口获取焦点时,软键盘也总是被隐藏的
【E】stateVisible:软键盘通常是可见的
【F】stateAlwaysVisible:用户选择activity时,软键盘总是显示的状态
【G】adjustUnspecified:默认设置,通常由系统自行决定是隐藏还是显示
【H】adjustResize:该Activity总是调整屏幕的大小以便留出软键盘的空间
【I】adjustPan:当前窗口的内容将自动移动以便当前焦点从不被键盘覆盖和用户能总是看到输入内容的部分
InputMethodManager常亮含义
public static final int HIDE_IMPLICIT_ONLY
hideSoftInputFromWindow(IBinder, int)中的标志,表示如果用户未显式地显示软键盘窗口,则隐藏窗口。
常量值: 1 (0x00000001)
public static final int HIDE_NOT_ALWAYS
hideSoftInputFromWindow(IBinder, int)中的标志,表示软键盘窗口总是隐藏,除非开始时以SHOW_FORCED显示。
常量值: 2 (0x00000002)
public static final int RESULT_HIDDEN
showSoftInput(View, int, ResultReceiver)和hideSoftInputFromWindow(IBinder, int, ResultReceiver)中ResultReceiver结果代码标志:软键盘窗口从显示切换到隐藏时的状态。
常量值: 3 (0x00000003)
public static final int RESULT_SHOWN
showSoftInput(View, int, ResultReceiver)和hideSoftInputFromWindow(IBinder, int, ResultReceiver)中ResultReceiver结果代码标志:软键盘窗口从隐藏切换到显示时的状态。
常量值: 2 (0x00000002)
public static final int RESULT_UNCHANGED_HIDDEN
showSoftInput(View, int, ResultReceiver)和hideSoftInputFromWindow(IBinder, int, ResultReceiver)中ResultReceiver结果代码标志:软键盘窗口不变保持隐藏时的状态。
常量值: 1 (0x00000001)
public static final int RESULT_UNCHANGED_SHOWN
showSoftInput(View, int, ResultReceiver)和hideSoftInputFromWindow(IBinder, int, ResultReceiver)中ResultReceiver结果代码标志:软键盘窗口不变保持显示时的状态。
常量值: 0 (0x00000000)
public static final int SHOW_FORCED
showSoftInput(View, int)标志,表示用户强制打开输入法(如长按菜单键),一直保持打开直至只有显式关闭。
常量值: 2 (0x00000002)
public static final int SHOW_IMPLICIT
showSoftInput(View, int)标志,表示隐式显示输入窗口,非用户直接要求。窗口可能不显示。
常量值: 1 (0x00000001)
https://www.cnblogs.com/weixing/p/3300908.html
public class KeyUtils {
/**
* 关闭软键盘
*
* @param context
*/
public static void closeKey(Context context, EditText editText) {
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
}
public static void openKey(Context context, EditText editText) {
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);// 得到InputMethodManager的实例
boolean active = imm.isActive();
imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT,
InputMethodManager.HIDE_NOT_ALWAYS);
}
}
