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

来源:互联网 发布:csgo举报机器人软件 编辑:程序博客网 时间:2024/05/30 23:47

如果一进去activity,EditText就获取焦点,弹出输入法界面,无疑是很影响美观的。关于让EditText失去焦点,网上比较多的做法是添加一个visibility=gone的Textview.然后让这个textView获取焦点。不知道是我人品不好还是怎么的。我这样做不行,后来采用另外一种做法,就是在其父组件(布局)上添加以下两句代码:

    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="姓名 单位名称 QQ 手机 电话 地址"              android:padding="10dp"              android:imeOptions="actionSearch"              android:singleLine="true"               android:textSize="13sp" />      </RelativeLayout>  


0 0
原创粉丝点击