My Android advanced tour ------> Android: windowSoftInputMode usage in android,
Interview question: How does one pop up the keyboard immediately when an Activity is displayed?
Answer: In the AndroidManifest. xml file, set the android: windowSoftInputMode attribute of the <activity> tag to pop up the keyboard of the current input method immediately when displaying the Activity (whether or not there is space for getting focus ).
Set to android: windowSoftInputMode = "stateVisible | adjustPan". The Code is 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 and enter the RingstonActivity. The current input method is displayed. I installed the sogou Input Method on my mobile phone.
================================== ==================================
Attributes: android: windowSoftInputMode
How the main window of the activity interacts with a keyboard window that contains the screen. The setting of this attribute will affect two things:
1> soft keyboard status-whether it is hidden or displayed-When Activity becomes the focus of user attention.
2> adjust the main window of the activity-whether to reduce the size of the main window to free up space for the soft keyboard or whether the current focus of its content is visible when the part of the activity window is covered by the soft keyboard.
It must be set to a value in the following list or a "state ..." Add "adjust…" to the value ..." Value combination. Set multiple values in any group-multiple "states ..." Values. For example, & mdash has undefined results. Use | to separate values. Example: <activity android: windowSoftInputMode = "stateVisible | adjustResize"...>
The value set here (except "stateUnspecified" and "adjustUnspecified") will overwrite the value set in the topic
The meanings of these values are as follows:
Value |
Description |
StateUnspecified |
The keyboard status (whether it is hidden or visible) is not specified. The system selects an appropriate status or topic-dependent setting. This is to set the default behavior of the software disk. |
StateUnchanged |
The keypad remains visible or hidden no matter what the last time it was, when the main window appears in front of it. |
StateHidden |
When the user selects the Activity, the soft keyboard is hidden-that is, when the user is sure to navigate to the Activity, instead of returning it because it leaves another Activity. |
StateAlwaysHidden |
The keyboard is always hidden when the Activity Main Window gets the focus. |
StateVisible |
The soft keyboard is visible when it is appropriate (when you navigate to the Activity main window ). |
StateAlwaysVisible |
When you select this Activity, the soft keyboard is visible-that is, when you are sure to navigate to this Activity, instead of returning it because it leaves another Activity. |
AdjustUnspecified |
It is not specified whether the Activity main window is adjusted to set aside space for the soft keyboard, or whether the content of the window is visible to the current focus on the screen. The system automatically selects one of these modes, depending on whether the content of the window has any layout view that can scroll their content. If there is such a view, the window will be adjusted. This assumption can make the content of the scrolling window visible in a small area. This is the default behavior settings for the main window. |
AdjustResize |
The main window of the Activity is always adjusted to the screen size so as to leave space on the keyboard. |
AdjustPan |
The main window of the Activity does not adjust the screen size to allow space on the keyboard. On the contrary, the content of the current window is automatically moved so that the current focus is not overwritten by the keyboard and the user can always see the part of the input content. This is usually not expected to be adjusted because the user may close the keyboard to obtain interaction with the covered content. |
Ouyang Peng |
Http://blog.csdn.net/ouyang_peng |
========================================================== The official website is as follows: ===
Syntax:
<activityandroid:windowSoftInputMode=["stateUnspecified", "stateUnchanged", "stateHidden", "stateAlwaysHidden", "stateVisible", "stateAlwaysVisible", "adjustUnspecified", "adjustResize", "adjustPan"] >
-
-
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 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 (|
). For example:
<activity android:windowSoftInputMode="stateVisible|adjustResize" . . . >
Values set here (other"stateUnspecified
"And"adjustUnspecified
") Override values set in the theme.
V alue |
Description |
"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. |
"stateUnchanged " |
The soft keyboard is kept in whatever state it was last in, whether visible or hidden, when the activity comes to the fore. |
"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. |
"stateAlwaysHidden " |
The soft keyboard is always hidden when the activity's main window has input focus. |
"stateVisible " |
The soft keyboard is visible when that's normally appropriate (when the user is navigating forward to the activity's main window ). |
"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. |
"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. |
"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. |
This attribute was introduced in API Level 3.
Introduced in:
API Level 1 for all attributes t
noHistory
And
windowSoftInputMode
, Which were added in API Level 3.
========================================================== ========================================================== ============================
Author: Ouyang Peng: Welcome to repost. sharing with others is the source of progress!
Reprinted Please retain the original address: http://blog.csdn.net/ouyang_peng
========================================================== ========================================================== ============================
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.