How to block the input box in Android

Source: Internet
Author: User

During layout, you may find that some of the input boxes are blocked and displayed completely, but the system comes with the SMS interface.
You can see the text message source code and modify the input mode. The source code is as follows:
Code method:
Getwindow (). setsoftinputmode (windowmanager. layoutparams. soft_input_adjust_resize |
Windowmanager. layoutparams. soft_input_state_hidden); // "I used this
You can also simply:
Getwindow (). setsoftinputmode (windowmanager. layoutparams. soft_input_adjust_pan );
XML method:
<Activity Android: Name = ". activity. mainactivity "Android: Label =" @ string/app_name "Android: windowsoftinputmode =" statehidden "Android: screenorientation =" portrait "Android: C/>
Soft input mode options:
Public int softinputmode;
The following options are related to the input mode:
Whether the soft input area is visible.
Public static final int soft_input_mask_state = 0x0f;
The status is not specified.
Public static final int soft_input_state_unspecified = 0;
Do not modify the status of the soft input area.
Public static final int soft_input_state_unchanged = 1;
Hide the Input Method Area (when the user enters the window ).
Public static final int soft_input_state_hidden = 2;
When the window gets focus, the input method area is hidden.
Public static final int soft_input_state_always_hidden = 3;
Display the Input Method Area (when the user enters the window ).
Public static final int soft_input_state_visible = 4;
When the window gets focus, the input method area is displayed.
Public static final int soft_input_state_always_visible = 5;
The window should be adjusted to adapt to the soft input window.
Public static final int soft_input_mask_adjust = 0xf0;
If the status is not specified, the system will try to select an input method style based on the window content.
Public static final int soft_input_adjust_unspecified = 0x00;
When the input method is displayed, the window size can be re-calculated so that the content is not overwritten by the input method.
It cannot be used together with soft_input_adjusp_pan. If neither of them is set, the system automatically sets an option based on the window content.
Public static final int soft_input_adjust_resize = 0x10;
Translation window when the input method is displayed. It does not need to handle size changes. The frame can move the window to ensure that the input focus is visible.
It cannot be used together with soft_input_adjust_resize. If neither of them is set, the system automatically sets an option based on the window content.
Public static final int soft_input_adjust_pan = 0x20;
When you go to this window, it is automatically set by the system, so do not set it.
This flag is automatically cleared when the window is displayed.
Public static final int soft_input_is_forward_navigation = 0x100;
The preceding options always solve your problem:
The following configuration solves the overwrite problem when various la s are nested on my interface.
<Activity Android: Name = ". activity. mainactivity" Android: Label = "@ string/app_name" Android: windowsoftinputmode = "adjustpan" Android: screenorientation = "portrait"/>

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.