Interaction of the interface with the soft keyboard in Android

Source: Internet
Author: User

One, configure in the list

<activity android:windowsoftinputmode= "Statevisible|adjustresize"/>

Meaning of each value:

"1" stateunspecified: The state of the soft keyboard is not specified, the system will select an appropriate state or a theme-dependent setting

"2" stateunchanged: When this activity appears, the soft keyboard will remain in the previous activity, whether it is hidden or displayed

"3" Statehidden: When the user chooses activity, the soft keyboard is always hidden

"4" Statealwayshidden: When the Activity main window gets the focus, the soft keyboard is always hidden

"5" statevisible: Soft keyboard is usually visible

"6" statealwaysvisible: When the user chooses activity, the soft keyboard always displays the state

"7" adjustunspecified: Default setting, usually determined by the system to hide or show

"8" adjustresize: The activity always adjusts the screen size to allow space for the soft keyboard

"9" Adjustpan: The contents of the current window will automatically move so that the current focus is never covered by the keyboard and the user can always see the part of the input content

Second, configure in the code

Method 1:

In OnCreate (), this. GetWindow (). Setsoftinputmode (WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

Method 2:

Hide IME

Inputmethodmanager IMM = (inputmethodmanager) getsystemservice (Context.input_method_service);
Imm.hidesoftinputfromwindow (Myedit.getwindowtoken (), 0); Myedit is a edittext that needs to be banned from automatically ejecting the soft keyboard

Method 3:

Hide IME
Inputmethodmanager IMM = (Inputmethodmanager) getapplicationcontext (). Getsystemservice (Context.input_method_ SERVICE);
Imm.togglesoftinput (0, inputmethodmanager.hide_not_always);

Note:

Togglesoftinput (whether or not shown, hidden);

This method converts the display state of the software input method to the form. If the IME is currently in display state, the method sets the IME to be hidden. If the IME is currently hidden, the method sets the IME display.

Interaction of the interface with the soft keyboard in Android

Related Article

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.