How to block edittext when the android virtual keyboard pops up

Source: Internet
Author: User

Use XML code on the activity node of manifest

<Activity Android: windowsoftinputmode = "adjustresize"/>

Android: the use of windowsoftinputmode.

How the activity interacts with the keyboard. The setting of this attribute will affect two things:

1> soft keyboard status-whether it is hidden or displayed-When activity becomes the focus of user attention.

2> adjust the main window of the activity-whether to reduce the size of the main window to free up space for the soft keyboard or whether the current focus of its content is visible when the part of the activity window is covered by the soft keyboard.

To hide the input method by default

  1. <Activity
  2. Android: Name = "viewactivity"
  3. Android: Label = "@ string/app_name"
  4. Android: windowsoftinputmode = "adjustunspecified | statehidden"
  5. Android: configchanges = "orientation | keyboardhidden">
  6. </Activity>

If the input method is displayed by default

 

  1. <Activity
  2. Android: Name = "viewactivity"
  3. Android: Label = "@ string/app_name"
  4. Android: windowsoftinputmode = "statevisible"
  5. Android: configchanges = "orientation | keyboardhidden">
  6. </Activity>

2:

Some mobile phones may fail to work using the appeal method. You can use the following methods:

Add scrollview to the layout file of edittext. When you click edittext, the widget slides and the scroll bar hides when the focus is lost.

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.