Android Keyboard Properties Windowsoftinputmode Dialysis

Source: Internet
Author: User

First of all, from the name of this property, we can intuitively see its role, this property is to set the window soft keyboard interactive mode.

The Android:windowsoftinputmode attribute has a total of 9 values, namely:

Stateunspecified,stateunchanged,statehidden,statealwayshidden,statevisible,statealwaysvisible, Adjustunspecified,adjustresize,adjustpan.

When we set properties, we can choose one of these 9 values, or we can use the state...| Adjust "in the form of settings. So how do these values affect the interaction between the soft keyboard and the window? Below, we will test each of these 9 values, in the end how to affect the display of the soft keyboard.

1.stateUnspecified

When we do not set the Android:windowsoftinputmode property, the software defaults to this interaction, the system will take the corresponding soft keyboard display mode according to the interface, for example, when there is only text and buttons on the interface, The soft keyboard does not eject automatically because there is no need to enter it. Then, when the interface appears on the focus of the input box, the soft keyboard will not automatically pop it? That's not necessarily true! The soft keyboard does not eject automatically. By default, the system does not determine whether the user needs a soft keyboard and therefore does not eject automatically. But why is that not necessarily? This is because, if we are outside of this layout, wrapping the previous scrollview, the soft keyboard will automatically bounce out!

This is indeed a very strange way of judging. Therefore, we can conclude that when the property is set to Stateunspecified, the system does not eject the soft keyboard by default, but when the interface of the input box with the focus has a scrolling requirement, it will automatically eject the soft keyboard. As for why you should emphasize the input box to get the focus, this is because, if the input box is not the focus, the soft keyboard will not automatically pop up, so that the interface does not automatically eject the soft keyboard one of the solutions, is in the XML file, set a non-input box control to get focus, thereby preventing the keyboard pop-up.

2.stateUnchanged

The meaning of the Chinese means that the state does not change, how should we understand this sentence? In fact, it is very well understood, that is, the current interface of the soft keyboard state, depending on the previous interface of the soft keyboard state. For example, if the current interface keyboard is hidden, then the interface after the jump, the soft keyboard is also hidden, if the current interface is displayed, then the interface after the jump, soft keyboard is also the display state.

3.stateHidden

when the user goes to an activity, the soft keyboard is hidden.

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.

4.stateAlwaysHidden

The soft keyboard is also hidden when the input focus is obtained in an activity.

5.stateVisible

Set to this property, you can summon the soft keyboard, even if there is no input box on the interface can be forced to summon out.

The soft keyboard is always hidden when the activity main window gets focus.

6.stateAlwaysVisible

This property can also summon the keyboard, but it is slightly different from the statevisible attribute. For example, when we set the Statevisible property, if the current interface keyboard is displayed, when we click the button to jump to the next interface, the soft keyboard will be hidden because the input box loses focus, when we return to the current interface, the keyboard this time is hidden. But if we set the statealwaysvisible, we jump to the next interface, the soft keyboard is still hidden, but when we come back again, the soft keyboard will be displayed. Therefore, this always explains the difference, regardless of the situation to reach the current interface (normal jump or the previous interface is returned by the user), the soft keyboard is displayed state.

Speaking of which, I think of the above Statehidden and Statealwayshidden, I guess the difference is the same, that is, Statealwayshidden is hidden anyway, but if you jump to the next interface, the soft keyboard is called out , then when the next interface is returned by the user, the keyboard should not be hidden, but I have not found a way to jump to the next interface, but also let the current interface soft keyboard does not disappear, so temporarily can not be verified.

7: " adjustUnspecified "

Does not specify whether the interface is resized to fit the location of the soft keyboard and input displayed on the interface, which is determined by the system by default.

8: " adjustResize "

Activity always adjusts the size of the space automatically to fit the soft keyboard (leaving room).

9: " adjustPan "

The current activity interface automatically moves content that is not overwritten by user input.



Android Keyboard Properties Windowsoftinputmode Dialysis

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.