Interview question: How do I eject a soft keyboard as soon as I show an activity?
Answer: Setting the Android:windowsoftinputmode property of the <activity> tag in the Androidmanifest.xml file will immediately pop up the current input method's soft keyboard when the activity is displayed ( Regardless of whether there is room for focus).
Set to: android:windowsoftinputmode= "Statevisible|adjustpan" code such as the following:
<activity android:name= ". Ringstonactivity " android:configchanges=" Orientation|keyboardhidden|screensize " android: Windowsoftinputmode= "Statevisible|adjustpan" android:label= "@string/app_name" android:theme= "@style/ Apptheme ">
Start the program, enter the ringstonactivity will pop up the current input method, my phone is installed Sogou Input method
================================= Chinese righteousness such as the following =================================
Attributes:android:windowSoftInputMode
How the active main form interacts with the soft keyboard forms that are included on the screen.
The setting of this property will affect two things:
1> the state of the soft keyboard-whether it is hidden or displayed-when the activity becomes the focus of the user's attention.
2> Active main form adjustment-whether to reduce the active main form size to make room for a soft keyboard or whether the current focus of its content is visible when part of the active form is overwritten by a soft keyboard.
It must be set to a value in the following list, or a "state ..." value plus a combination of "adjust ..." values. Set multiple values in either group-multiple "state ..." values, such as &mdash have no defined results. Each value is separated by | For example: <activity android:windowsoftinputmode= "Statevisible|adjustresize" ... >
The value set in this (except "stateunspecified" and "adjustunspecified") overrides the value set in the topic
The following are the meanings of these values:
Value |
Meaning |
Stateunspecified |
The state of the soft keyboard (whether it is hidden or visible) is not specified. The system will select an appropriate state or a theme-dependent setting. This is the default setting for the software disk behavior. |
Stateunchanged |
The soft keyboard is maintained regardless of its last state, visible or hidden, when the main form is now in front of it. |
Statehidden |
When the user chooses the activity, the soft keyboard is hidden-that is, when the user determines that the activity is navigated to. Instead of returning to it because there is an activity left. |
Statealwayshidden |
The soft keyboard is always hidden. When the activity main form gets the focus. |
Statevisible |
The soft keyboard is visible when that is normal (when the user navigates to the activity main form). |
Statealwaysvisible |
When the user chooses this activity. The soft keyboard is visible-that is, when the user determines to navigate to the activity, instead of returning to it because there is an activity left. |
Adjustunspecified |
It is not specified whether the activity main form resizes to allow space on the soft keyboard, or whether the contents on the form get visible on the screen where the current focus is. The system will voluntarily choose one of these patterns primarily depending on whether the content of the form has any layout view that can scroll their content. If you have such a view, this form will resize, if you can make the contents of the scrolling form visible in a smaller area. This is the default behavior setting for the main form. |
Adjustresize |
The activity main form is always resized on the screen to allow space on the soft keyboard. |
Adjustpan |
The activity main form does not adjust the size of the screen to allow space for the soft keyboard. Instead, the contents of the current form will be actively moved so that the current focus is never covered by the keyboard and the user can always see the part of the input. This is generally not expected than resizing, because the user may turn off the soft keyboard in order to get an interactive operation with the covered content. |
Ouyangpeng |
Http://blog.csdn.net/ouyang_peng |
======================================== Official Website Introduction For example the following ========================================
The syntax is as follows:
<activityandroid:windowsoftinputmode=["Stateunspecified", "stateunchanged", "Statehidden", " Statealwayshidden "," statevisible ", " statealwaysvisible "," adjustunspecified ",
-
-
-
-
android:windowSoftInputMode
-
How the main window of the activity interacts with the window containing the on-screen soft keyboard. The setting for this attribute affects the 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's resized smaller to make the hostel for the soft keyboard or WH Ether its contents pan to make the current focus visible if part of the window is covered by the soft keyboard.
the setting must is one of the values listed in the following table, or a C Ombination of one "state ...
" value plus One "adjust ...
" value. Setting multiple values in either Group-multiple " state ...
" values, for Example-has undefined results. Individual values is separated by a vertical bar ( |
). For example:
<activityandroid:windowsoftinputmode="Statevisible|adjustresize" >
Values set here (other than "and stateUnspecified
" adjustUnspecified
) override the values set in the theme.
v alue |
description |
" stateunspecified " |
The State of the soft keyboard (whether it was hidden or visible) is not specified. The system would choose an appropriate state or rely on the setting in the Theme. this is the default setting for the behavior of the soft keyboard. |
" stateunchanged " |
The Soft keyboard is kept in whatever state it's last inch, whether visible or hidden, when the activity comes to the fore. |
" statehidden " | TD style= "PADDING:4PX 12px; border:1px solid RGB (221,221,221); Vertical-align:top; Background-color:inherit ">the soft keyboard is hidden when the user chooses the activity-that was, when the user Affirmat Ively navigates forward to the activity, rather than backs into it because of leaving another activity.
"stateAlwaysHidden " |
The soft keyboard is always hidden when the activity's main window has input focus. |
"stateVisible " |
The soft keyboard is visible if that's normally appropriate (when the user was navigating forward to the activity ' s main window). |
" statealwaysvisible " |
The soft keyboard is made visible when the user chooses the activity-that are, when the user affirmatively navigates forw ARD to the activity, rather than backs into it because of leaving another activity. |
" adjustunspecified " |
It is unspecified whether the activity's main window resizes to make the soft keyboard, or whether the contents O f the window pan to make the current focus visible on-screen. The system would automatically select one of these modes depending on whether the content of the window have any layout view s that can scroll their contents. If There is such a view, the window would be resized, on the assumption that scrolling can make all of the window's content s visible within a smaller area. this is the default setting for the behavior of the main window. |
" adjustresize " |
The Activity ' s main window is always resized to make, the soft keyboard on screen. |
"adjustPan " |
The activity's main window is not a resized to make hostel for the soft keyboard. Rather, the contents of the window is automatically panned so, the current focus was never obscured by the keyboard an D users can always see what they is typing. This was generally less desirable than resizing, because the user could need to close the soft keyboard to get at and Interac T with obscured parts of the window. |
This attribute is introduced in API level 3.
Introduced in:
API level 1 for all attributes except for
noHistory
and
windowSoftInputMode
, which were added in API level 3.
====================================================================================
Ouyangpeng Welcome reprint. Sharing with others is the source of progress!
Reprint please keep the original address : Http://blog.csdn.net/ouyang_peng
====================================================================================
My Android Step-by-step tour------> How to use Android:windowsoftinputmode in Android