Solution to the Problem of input method occlusion on the Android platform

Source: Internet
Author: User

Solution to the Problem of input method occlusion on the Android platform

In the Android system, due to the limitation of the phone screen size, the pop-up input method panel usually occupies most of the screen when character input is required. If the input box is just below, it is often the embarrassment of being blocked by the input method panel, which brings great troubles to users and unfriendly user experience.

Check the android SDK instructions and find that you can solve this problem by setting an attribute of the activity. For example, you can write in androidmanifest. XML as follows:

<Activity Android: Name = ". categorylist"
Android: Label = "@ string/app_name"
Android: windowsoftinputmode = "statevisible | adjustpan">
</Activity>

Here, Android: windowsoftinputmode is used to avoid the problem of blocking the input method panel. For specific parameter descriptions, see the SDK documentation. However, it indicates that this attribute is added after Android 1.5, that is, the SDK after API Level 3 is supported. What should I do if I don't use it on machines like Lenovo O1? Fortunately, I found another solution, scrollview. We can add a scrollview to the top-level element of the corresponding layout XML. In this way, all text boxes will automatically scroll up when the input method panel is popped up. The sample code is as follows:

<Scrollview xmlns: Android = "http://schemas.android.com/apk/res/android"
Android: layout_width = "fill_parent"
Android: layout_height = "fill_parent">
<Linearlayout Android: Orientation = "vertical"
Android: layout_width = "fill_parent"
Android: layout_height = "fill_parent">
<Edittext Android: Id = "@ + ID/content"
Android: layout_width = "fill_parent"
Android: layout_height = "wrap_content"
Android: lines = "4"
Android: scrollbars = "vertical"
Android: gravity = "fill_horizontal"/>
</Linearlayout>
</Scrollview>

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.