Android removes the default focus on EditView

Source: Internet
Author: User

Looking for a long time on the internet, a bit of listening to soft keyboard events, a bit called Clearfouse () method, but the test has not! The corresponding property could not be found in the XML to turn off this default behavior

Solution: Find one in the parent control of the EditText, set to

The code is as follows Copy Code

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

In this way, the default behavior of the EditText is truncated!

The code is as follows Copy Code

< LinearLayout
style= "@style/fillwrapwidgetstyle"
android:orientation= "vertical"
android:background= "@ Color/black "
android:gravity=" Center_horizontal
android:focusable= "true"
Android: Focusableintouchmode= "true"
>
<imageview
android:id= "@+id/logo"
style= "@style/ Wrapcontentwidgetstyle "
android:background=" @drawable/dream_dictionary_logo
/>
<relativelayout
style= "@style/fillwrapwidgetstyle"
android:background= "@drawable/searchbar_bg"
android:gravity= " Center_vertical "
>
<edittext
android:id=" @+id/searchedittext "
style=" @style/ Wrapcontentwidgetstyle "
android:background=" @null
android:hint= "Search"
android:layout_marginleft= " 40DP '
android:singleline= ' true '
/>
</RelativeLayout>
</linearlayout>

After consulting a lot of data, the following methods are found to be the simplest:

In XML, before the EditText control
Join

The code is as follows Copy Code

<linearlayout
Android:id= "@+id/linearlayout_focus"
Android:focusable= "true"
Android:focusableintouchmode= "true"
Android:layout_width= "0px"
android:layout_height= "0px"/>

This is a false linearlayout, will not show, but will steal the focus

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.