Interview question: How do I eject a soft keyboard as soon as an activity is displayed?
Answer: Setting the Android:windowsoftinputmode property of the <activity> tag in the Androidmanifest.xml file can immediately eject 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 as follows:
<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 is as follows =================================
Attributes:android:windowSoftInputMode
How the active main window interacts with the Soft keyboard window on the containing 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 window adjustment-whether to reduce the active main window size to make room for a soft keyboard or whether the current focus of its content is visible when part of the active window is overwritten by a soft keyboard.
it must be set to a value in the list below, or a "state ..." value plus a combination of "adjust ..." values. Set multiple values in either group-multiple "state ..." values, such as &mdash, have undefined results. Each value is separated by | Example: <activity android:windowsoftinputmode= "Statevisible|adjustresize" ... >
The value set in this (except "stateunspecified" and "adjustunspecified") overrides the value set in the topic
Here 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 persisted regardless of its last state, whether visible or hidden, when the main window appears in front. |
| 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 due to leaving another activity. |
| Statealwayshidden |
The soft keyboard is always hidden when the activity main window gets focus. |
| Statevisible |
The soft keyboard is visible when that is normal (when the user navigates to the Activity main window). |
| < Span style= "font-size:18px" >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 due to leaving another activity. |
| Adjustunspecified |
It is not specified whether the Activity main window is resized to allow space on the soft keyboard, or whether the contents of the window are visible on the screen where the current focus is. The system will automatically select one of these modes primarily depending on whether the contents of the window have any layout view that can scroll their content. If there is such a view, the window will be resized so that the contents of the scrolling window can be visible in a smaller area. This is the default behavior setting for the main window. |
| Adjustresize |
The Activity main window is always resized on the screen to allow space for the soft keyboard. |
| Adjustpan |
the Activity main window does not adjust the size of the screen to allow space for the soft keyboard. Instead, the contents of the current window are automatically 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 usually 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 introduces 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; Vertical-align:top; Background-color:inherit; border:1px solid RGB (221,221,221) ">the soft keyboard is hidden when the user chooses the activity-that was, when the user Affirmatively 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
noHistoryand
windowSoftInputMode, which were added in API level 3.
==================================================================================================
Ouyangpeng welcome reprint, sharing with people is the source of progress!
Reprint please keep the original address : Http://blog.csdn.net/ouyang_peng
==================================================================================================
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
My Android Advanced tour------The usage of Android:windowsoftinputmode in >android