Android 让EditText失去焦点避免自动弹出输入法

来源:互联网 发布:windows培训机构 编辑:程序博客网 时间:2024/05/17 18:24

如果一进去activity,EditText就获取焦点,弹出输入法界面,无疑是很影响美观的。可以在其父组件(布局)上添加以下两句代码:

android:focusable="true"   android:focusableInTouchMode="true"

比如:
<RelativeLayout    android:layout_width="match_parent"     android:layout_height="40dp"    android:gravity="center_vertical"    android:background="#ffffff"    android:focusable="true"     android:focusableInTouchMode="true"    >    <EditText         android:layout_alignParentLeft="true"        android:id="@+id/searchWordET"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:background="#ffffff"        android:hint="手机/邮箱"        android:padding="10dp"        android:imeOptions="actionSearch"        android:singleLine="true"         android:textSize="13sp" /></RelativeLayout>

0 0
原创粉丝点击