The keyboard of Android development automatically pops up on edittext

Source: Internet
Author: User

The app UI has multiple views, including edittext. after entering the interface, the focus automatically falls on the first edittext and a soft keyboard is displayed.

There are two ways to solve this problem:

1. Transfer the focus to another view: in the XML file, add the following two rows to the attribute of the target view,

Android: focusable = "true" Android: focusableintouchmode = "true"

In this way, the focus is not on edittext, and the soft keyboard will not pop up.

2. Hide the keyboard so that it does not pop up automatically: in the manifest file, add the following settings to the corresponding acitivity attribute,

Android: windowsoftinputmode = "statealwayshidden"

In this way, you can see that the focus is still on edittext, but the soft keyboard does not pop up. Click edittext by hand. The soft keyboard will pop up normally.

Summary: if you do not want the initial focus to be displayed on edittext or the soft keyboard to be displayed, you can use method 1. If you want the prompt initialization focus to remain on edittext, but do not bring up the soft keyboard, method 2 is available. If you only want to suppress the automatic pop-up of the soft keyboard, either of them can be used.

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.