请选择 进入手机版 | 继续访问电脑版

Android输入法弹出时界面被挤压的问题

[复制链接]
谭先生 发表于 2021-1-1 18:31:14 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题
android:windowSoftInputMode
Activity 的主窗口与包罗屏幕软键盘的窗口之间的交互方式。该属性的设置会影响两点内容:
1.当 Activity 成为用户注意的焦点时,软键盘的状态为隐藏还是可见。
2.对 Activity 主窗口所做的调解 — 是否将其尺寸调小,为软键盘腾出空间;或当软键盘遮盖部分窗口时,是否平移其内容以使当前焦点可见。
值形貌“stateUnspecified”不指定软键盘的状态(隐藏还是可见)。系统会选择符合的状态,或依赖主题中的设置。这是对软键盘行为的默认设置。“stateUnchanged”当 Activity 转至前台时生存软键盘最后所处的任何状态,无论是可见还是隐藏。“stateHidden”当用户选择 Activity 时(换言之,当用户确实是向前导航到 Activity,而不是因脱离另一 Activity 而返回时)隐藏软键盘。“stateAlwaysHidden”当 Activity 的主窗口有输入焦点时始终隐藏软键盘。“stateVisible”在正常的适宜情况下(当用户向前导航到 Activity 的主窗口时)显示软键盘。“stateAlwaysVisible”当用户选择 Activity 时(换言之,当用户确实是向前导航到 Activity,而不是因脱离另一 Activity 而返回时)显示软键盘。“adjustUnspecified”不指定 Activity 的主窗口是否通过调解尺寸为软键盘腾出空间,大概是否通过平移窗口内容以在屏幕上显示当前焦点。根据窗口的内容是否存在任何可滚动其内容的布局视图,系统会自动选择此中一种模式。如果存在这种视图,系统会调解窗口尺寸,前提是可通过滚动利用在较小区域内看到窗口的所有内容。这是对主窗口行为的默认设置。“adjustResize”始终调解 Activity 主窗口的尺寸,以为屏幕上的软键盘腾出空间。“adjustPan”不通过调解 Activity 主窗口的尺寸为软键盘腾出空间。相反,窗口的内容会自动平移,使键盘永远无法遮盖当前焦点,以便用户始终能看到自己输入的内容。这通常不如调解窗口尺寸可取,因为用户可能需关闭软键盘才气进入被遮盖的窗口部分,并与之举行交互。public static final int windowSoftInputMode
Defines the default soft input state that this window would like when it is displayed. Corresponds to WindowManager.LayoutParams.softInputMode.
Must be one or more (separated by ‘|’) of the following constant values.
ConstantValueDescriptionadjustNothing30Don’t resize or pan the window to make room for the soft input area; the window is never adjusted for it.adjustPan20Don’t resize the window to make room for the soft input area; instead pan the contents of the window as focus moves inside of it so that the user can see what they are typing. This is generally less desireable than panning because the user may need to close the input area to get at and interact with parts of the window.adjustResize10Always resize the window: the content area of the window is reduced to make room for the soft input area.adjustUnspecified0The window resize/pan adjustment has not been specified, the system will automatically select between resize and pan modes, depending on whether the content of the window has any layout views that can scroll their contents. If there is such a view, then the window will be resized, with the assumption being that the resizeable area can be reduced to make room for the input UI.stateAlwaysHidden3Always make the soft input area hidden when this window has input focus.stateAlwaysVisible5Always make the soft input area visible when this window has input focus.stateHidden2Make the soft input area hidden when normally appropriate (when the user is navigating forward to your window).stateUnchanged1Leave the soft input window as-is, in whatever state it last was.stateUnspecified0Not specified, use what the system thinks is best. This is the default.stateVisible4Make the soft input area visible when normally appropriate (when the user is navigating forward to your window).参考文章:
https://developer.android.com/guide/topics/manifest/activity-element#wsoft
https://developer.android.com/reference/android/R.attr.html#windowSoftInputMode
在AndroidManifest.xml中修改:
增加android:windowSoftInputMode=“adjustPan”,修改后发现无效果,界面依旧被输入法挤压。
  1.                                                                         
复制代码
增加android:windowSoftInputMode=“adjustNothing”,生效,界面不会被挤压。
  1.                                                                         
复制代码
来源:https://blog.csdn.net/Sunxiaolin2016/article/details/111947770
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则


专注素材教程免费分享
全国免费热线电话

18768367769

周一至周日9:00-23:00

反馈建议

27428564@qq.com 在线QQ咨询

扫描二维码关注我们

Powered by Discuz! X3.4© 2001-2013 Comsenz Inc.( 蜀ICP备2021001884号-1 )