Android pop-up soft keyboard Android:windowsoftinputmode Settings Summary

Source: Internet
Author: User

When the input box is too large in the layout design of Android, the input box below will be partially blocked by the software disk when the soft keyboard is entered, so the focus input cannot be obtained. or a button with a framentlayout suspended at the bottom will also block the input box.

First, the solution

Method One:

Write this Code GetWindow () before setcontentview in your activity's oncreate. Setsoftinputmode (WindowManager.LayoutParams.SOFT_INPUT _adjust_pan);

Method Two:
Add android:windowsoftinputmode= "Statevisible|adjustresize" to the interface corresponding to the <activity> in the Androidmanifest.xml file of the project. This will make the screen move up the whole. If you add the android:windowsoftinputmode= "Adjustpan", the keyboard will overwrite the screen.

Method Three:

Replace the top layout with ScrollView, or add a layer of ScrollView to the top layout. This will roll the soft keyboard and the input box together, and the soft keyboard will always be at the bottom.

Summarize:

I am usually method two with method 31 to use, certainly no problem, method recommended not so use.

Do not want occlusion set activity property android:windowsoftinputmode= "Adjustpan"

Want to dynamically adjust height android:windowsoftinputmode= "Adjustresize"

second, take a look at the description of the other property values

1, "stateunspecified"

The state of the soft keyboard (whether it is hidden or visible) is not specified. The system will select an appropriate state or a theme-dependent setting.

This is the default setting for the software disk behavior.

2, "stateunchanged"

The soft keyboard is persisted regardless of its last state, whether visible or hidden, when the main window appears in front.

3, "Statehidden"

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 always hidden when the activity main window gets focus.

5, "statevisible"

The soft keyboard is visible when that is normal (when the user navigates to the Activity main window).

6, "Statealwaysvisible"

When the user chooses this activity, the soft keyboard is visible-that is, when the user determines that the activity is navigated to, rather than returning to it due to leaving another activity.

7, "Adjustunspecified"

It is not specified whether the Activity main window is resized to allow space on the soft keyboard, or whether the contents of the window are visible on the screen where the current focus is. The system will automatically select one of these modes primarily depending on whether the contents of the window have any layout view that can scroll their content. If there is such a view, the window will be resized so that the contents of the scrolling window can be visible in a smaller area. This is the default behavior setting for the main window.

8, "Adjustresize"

The Activity main window is always resized on the screen to allow space for the soft keyboard

9, "Adjustpan"

The Activity main window does not adjust the size of the screen to allow space for the soft keyboard. Instead, the contents of the current window are automatically moved so that the current focus is never covered by the keyboard and the user can always see the part of the input. This is usually not expected than resizing, because the user may turn off the soft keyboard in order to get an interactive operation with the covered content.

Android pop-up soft keyboard Android:windowsoftinputmode Settings Summary

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.