android 弹出软键盘属性windowSoftInputMode

1、简介app

软件盘设置,会如下面两种方式影响屏幕的显示less

一、设置为“可见”或者“不可见”布局

stateUnchanged、stateHidden、stateAlwaysHidden、stateVisible、stateAlwaysVisiblespa

二、软键盘的展现方式会影响主界面的布局,例如能够是屏幕原有布局改变尺寸,留给软键盘足够的空间。orm

也多是,原有布局不变,软键盘覆盖在布局上面。ci

adjustUnspecified、adjustResize、adjustPan、adjustNothingget

设置时,能够设置单一一个属性,或者一个state...加上一个adjust...input


2、共有如下十种属性it

下面分别介绍如下每种属性的表现io

一、stateUnspecified

The state of the soft keyboard (whether it is hidden or visible) is not specified. The system will choose an appropriate state or rely on the setting in the theme.

This is the default setting for the behavior of the soft keyboard.

这种属性表示,软键盘显示或者不显示没有设定。系统会x选择一个合适的状态,或者根据主题设置的属性来反应。

这个是软键盘的默认属性

二、stateUnchanged

The soft keyboard is kept in whatever state it was last in, whether visible or hidden, when the activity comes to the fore.

设置这种属性后,当activity显示在最上层的时候、软键盘会保持上一个状态,不管是可见或者不可见

三、stateHidden

The soft keyboard is hidden when the user chooses the activity — that is, when the user affirmatively navigates forward to the activity, rather than backs into it because of leaving another activity.

设置这一属性后、当activity是被明确的打开的时候软键盘设置为隐藏状态。但若是是从另一个activity返回到当前界面则不会设置。

四、stateAlwaysHidden

The soft keyboard is always hidden when the activity's main window has input focus.

设置这一属性后、当activity在最上层显示时,软键盘就会处于隐藏状态

五、stateVisible

The soft keyboard is visible when that's normally appropriate (when the user is navigating forward to the activity's main window).

设置这一属性后、当activity是被主动打开的时候软键盘设置为显示状态。

六、stateAlwaysVisible

The soft keyboard is made visible when the user chooses the activity — that is, when the user affirmatively navigates forward to the activity, rather than backs into it because of leaving another activity.

设置这一属性后、当activity是被明确的打开的时候软键盘设置为可见状态。但若是是从另一个activity返回到当前界面则不会设置。

七、adjustUnspecified

It is unspecified whether the activity's main window resizes to make room for the soft keyboard, or whether the contents of the window pan to make the current focus visible on-screen. The system will automatically select one of these modes depending on whether the content of the window has any layout views that can scroll their contents. If there is such a view, the window will be resized, on the assumption that scrolling can make all of the window's contents visible within a smaller area.

This is the default setting for the behavior of the main window.

设置这种属性表示,activity没有设定是选择从新设定尺寸,使软键盘有足够的空间显示,或者软键盘覆盖在原有layout的上面。系统会自动选择一个模式,这个依赖于界面上是否有一个能够滚动的view来滚动界面上的内容。若是有一个这样的view,假定滚动可使全部的内容在一个更小的位置上显示,则窗口会改变尺寸为软键盘提供空间。

八、adjustResize

The activity's main window is always resized to make room for the soft keyboard on screen.

界面老是会改变尺寸为软键盘提供空间显示。

九、adjustPan

The activity's main window is not resized to make room for the soft keyboard. Rather, the contents of the window are automatically panned so that the current focus is never obscured by the keyboard and users can always see what they are typing. This is generally less desirable than resizing, because the user may need to close the soft keyboard to get at and interact with obscured parts of the window.

主界面不会改变尺寸。窗口会自动的被覆盖,并且当前的焦点会一直保持不会变,用户一直处于正在打印状态。这种属性不多使用,由于这样会致使用户必须关闭软键盘才能操做灰显部分窗口。

十、adjustNothing

不作任何自适应。