Android removes EditView's default focus issue

Source: Internet
Author: User

Solution: Find one in EditText's parent control, set it to

The code is as follows Copy Code

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

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

The code is as follows Copy Code

<linearlayout 
style= "@style/fillwrapwidgetstyle" &NBSP;
android:orientation= "Vertical"  
android:background= "@color/black" &NBSP;
android:gravity= "Center_horizontal" &NBSP;
android:focusable= "true" &NBSP;
Android:focusableintouchmode= "true" &NBSP;
> 
<imageview 
android:id= " @+id/logo "&NBSP;
style=" @style/wrapcontentwidgetstyle "&NBSP;
android:background=" @drawable/dream_ Dictionary_logo "&NBSP;
/> 
<relativelayout 
style=" @style/fillwrapwidgetstyle " 
android:background= "@drawable/searchbar_bg" &NBSP;
android:gravity= "center_vertical" &NBSP;
> 
<edittext 
android:id= "@+id/searchedittext" &NBSP;
style= "@style/wrapcontentwidgetstyle"  
android:background= "@null" &NBSP;
android:hint= "Search" &NBSP;
android:layout_marginleft= "40DP"  
Android:singleline= "true" &NBSP;
/> 
</relativelayout> 
</linearlayout

After reviewing a lot of data, the following methods are 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"/>

It's a fake linearlayout, it's not going to show, but it's going to steal the spotlight.

Android removes EditView's default focus issue

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.