您的位置:首页 > 移动开发 > Android开发

【小技巧】让Android EditText失去焦点,防止自动弹出键盘

2015-07-27 15:23 543 查看
一、介绍:

刚刚做的小程序,有个EditText的控件自动获取焦点,一进入程序就弹出虚拟键盘。

二、解决办法:

1.刚刚从网上查到,(但是不管用)

在EditText的父控件加入以下属性

android:focusable="true"
                android:focusableInTouchMode="true"
如下:

<LinearLayout
android:layout_width="244dp"
android:layout_height="match_parent"
android:layout_weight="0.83"
android:focusable="true" android:focusableInTouchMode="true"
android:orientation="horizontal" >

<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="2"
android:background="@drawable/et_1_shape"
android:ems="6"
android:hint="输入标题内容"
android:textSize="20dp" >
</EditText>
<requestFocus />
 </LinearLayout>
2.原来是多了个<requestForcus />的标签,去掉就好了……

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: