Android keyboard attribute windowSoftInputMode dialysis, windowsoftinputmode
First, we can intuitively see its role from the name of this attribute, which is used to set the Interactive Mode of the window keypad.
Android: windowSoftInputMode attributes have a total of nine values:
StateUnspecified, stateUnchanged, stateHidden, stateAlwaysHidden, stateVisible, stateAlwaysVisible, adjustUnspecified, adjustResize, adjustPan.
When setting attributes, you can select one of the nine values or set them in the form of "state... | adjust. So how did these values affect the interaction between the keyboard and the window? Next, we will test these nine values one by one to see how they affect the display of the soft keyboard.
1. stateUnspecified
The State is not specified. When the android: windowSoftInputMode attribute is not set, the software uses this interactive mode by default. The system uses the corresponding display mode of the soft keyboard based on the interface, for example, when there are only text and buttons on the interface, the keyboard will not pop up automatically, because there is no need to input. Then, when an input box for getting the focus is displayed on the interface, will the keyboard automatically pop up? Not necessarily! The keyboard does not pop up automatically. By default, the system does not determine whether the user needs a soft keyboard, so it will not pop up automatically. But why not? This is because if we wrap a ScrollView outside the layout, the soft keyboard will pop up automatically!
This is indeed a strange way of judging. Therefore, we can conclude that when the attribute is set to stateUnspecified, the soft keyboard is not displayed by default. However, when the UI of the input box with the focus is required to scroll, the keyboard is automatically displayed. Why do you need to emphasize the input box for getting the focus? If the focus is not obtained from the input box, the keyboard will not pop up automatically, so that one solution of the Soft Keyboard will not pop up automatically on the interface, in the xml file, set a non-input box control to get the focus, so as to prevent the keyboard from popping up.
2. stateUnchanged
Chinese means that the State does not change. How should we understand this sentence? In fact, it is easy to understand, that is, the current interface's soft keyboard status depends on the soft keyboard status of the previous interface. For example, if the current interface keyboard is hidden, the interface after the jump is also hidden; if the current interface is displayed, the interface after the jump is displayed, the keyboard is also displayed.
3. stateHidden
When a user moves to an activity, the keyboard is hidden.
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.
4. stateAlwaysHidden
When an activity obtains the input focus, the keyboard is also hidden.
5. stateVisible
Set this attribute to summon the soft keyboard, even if there is no input box on the interface, it can be forcibly summoned.
The keyboard is always hidden when the Activity Main Window gets the focus.
6. stateAlwaysVisible
This property can also summon the keyboard, but it is slightly different from the stateVisible property. For example, when we set it to the stateVisible attribute, if the current interface keyboard is displayed, when we click the button to jump to the next interface, the keyboard is hidden because the input box loses its focus. When we return to the current interface again, the keyboard is hidden. But if we set stateAlwaysVisible, we will jump to the next interface, and the soft keyboard will be hidden. But when we come back, the soft keyboard will be displayed. Therefore, this Always explains the difference. The soft keyboard displays the status no matter when the current interface is reached (normal jump or the previous interface is returned by the user.
Speaking of this, I think of the above stateHidden and stateAlwaysHidden. I guess the same is true. That is to say, stateAlwaysHidden is hidden in any way, but if you jump to the next interface, when the soft keyboard is summoned, the keyboard will not be hidden when the current interface is returned by the user. However, I have not found a way to jump to the next interface, this method does not disappear the keyboard of the current interface, so it cannot be verified for the time being.
7 :"adjustUnspecified"
Whether or not to adjust the size of the interface to adapt to the position where the keyboard and input content are displayed on the interface is determined by default.
8 :"adjustResize"
Activity always automatically adjusts the space size to adapt to the soft keyboard (leave space ).
9 :"adjustPan"
The current activity page is automatically moved so that the content entered by the user is not overwritten.