windowSoftInputMode为Android中activity在Manifest.xml中设置的属性之一,主要用于解决屏幕软键盘与Activity布局的问题。

官方说明如下:

How the main window of the activity interacts with the window containing the on-screen soft keyboard. The setting for this attribute affects two things:

  • The state of the soft keyboard — whether it is hidden or visible — when the activity becomes the focus of user attention.
  • The adjustment made to the activity's main window — whether it is resized smaller to make room for the soft keyboard or whether its contents pan to make the current focus visible when part of the window is covered by the soft keyboard.

The setting must be one of the values listed in the following table, or a combination of one "state..." value plus one "adjust..." value. Setting multiple values in either group — multiple "state..." values, for example — has undefined results. Individual values are separated by a vertical bar (|).

大意为,该属性主要用于描述activity窗口与软键盘窗口的交互,设置该属性主要会影响两个方面:

  • 软键盘的状态:当Activity被用户获取焦点时,软键盘是显示还是隐藏
  • Activity窗口的调整:是否通过缩小原视图来为软键盘获取足够的空间,是否通过覆盖的方式来为软键盘获取足够的空间
设置的属性必须是下表的参数之一,或是由“state...”(改变软键盘状态)和"adjust...”(改变Activity窗口调整状态)组合而成,由“|”符号组合两个参数。
windowSoftInputMode参数表
描述
stateUnspecified 软键盘的状态未指明,系统会自动根据选择的主题信息执行相应的行为,是系统默认选项
stateUnchanged 当该Activity来到前台时,软键盘保持其原有的状态(在前一个Activity中显示就继续显示,隐藏就继续隐藏)
stateHidden 当该Activity是被直接打开时,隐藏软键盘,当该Activity是由按下back键打开时,保持软键盘状态
stateAlwaysHidden 只要进入该Activity软键盘就会被隐藏
stateVisible 当该Activity是被直接打开时,显示软键盘,当该Activity是由按下back键打开时,保持软键盘状态
stateAlwaysVisible 只要进入该Activity软键盘就会被显示
adjustUnspecified Activity窗口的调整未指明,系统会自动根据选择的主题信息执行相应的行为,是系统默认选项,如果存在ScrollView
会使用缩小视图的方式,否则使用覆盖的方式
adjustResize 使用缩小视图的方式来为软键盘腾出空间,意味着整体布局底部会上移,空间会缩小,控件可能会挤到一起
adjustPan 通过覆盖的方式来为软键盘获取足够的空间,软键盘会覆盖布局底部控件,要是软键盘盖住了当前输入框的时候整体
布局会往上移动

更多相关文章

  1. Android实现电话状态监控
  2. android键盘事件
  3. android检测网络状态
  4. android 开发收银系统,弹出键盘固定界面UI的方法
  5. Android 去掉状态栏 去掉标题栏 沉浸式状态栏 状态栏重叠 布局重
  6. Android应用程序键盘(Keyboard)消息处理机制分析(10)
  7. Android应用程序键盘(Keyboard)消息处理机制分析(21)
  8. Android 自定义键盘中禁用点击预览弹窗

随机推荐

  1. Android控件指定方向加边框
  2. Android(安卓)- 永不锁屏,开机不锁屏,删除
  3. vuforia android 教程(1) 利用vuforia an
  4. C#服务端+C#客户端+android客户端,socket
  5. Android的GridView控件点击图片变暗效果
  6. Using color in Android, by XML
  7. Android获取声音长度
  8. classList对象、blur事件进行表单非空验
  9. 简单淘宝首页案例
  10. vue 常用术语,样式与事件绑定,列表渲染的