<强>最近在通讯录新建联系人=中,一进入一个页面,EditText默认就会自动获取焦点,很是郁闷,如何让EditText不自动获取焦点吗? 强>
<强>那么如何取消这个默认行为呢? 强>
在网上找了好久,有点监听软键盘事件,有点调用clearFouse()方法,但是测试了都没有! xml中也找不到相应的属性可以关闭这个默认行为
<>强解决之道:在EditText的父级控件中找一个,设置成强>
android: focusable=" true " android: focusableInTouchMode=" true "
& lt; & # 63; xml version=" 1.0 " encoding=" utf - 8 " & # 63;比; & lt; RelativeLayout xmlns: android=" http://schemas.android.com/apk/res/android " android: layout_width="宽和" android: layout_height="宽和" android:背景=" # ffffff " android: baselineAligned=" false " android: focusable=" true " android: focusableInTouchMode=" true "比; & lt;使用 android: layout_width=" 250 dp” android: layout_height=" wrap_content " android: id=癅 + id/txtLayout” android: layout_marginTop=" 20 dp” android: layout_centerHorizontal=" true " 比; EditText & lt; android: layout_width="宽和" android: layout_height=" 35 dp” android: id=癅 + id/editPhone” android: phoneNumber=" true " android:文本=" @string/txtaddPhone” android:输入textColor=" # D8D8D8” android:背景=" @drawable/txtupbg” android: textSize=" 15 dp "/比; & lt;/RelativeLayout> & lt;/RelativeLayout>
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,同时也希望多多支持!