最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
Android取消EditText自动获取默认焦点
时间:2022-06-25 23:27:35 编辑:袖梨 来源:一聚教程网
最近在通讯录新建联系人=中,一进入一个页面, EditText默认就会自动获取焦点,很是郁闷, 如何让EditText不自动获取焦点?
那么如何取消这个默认行为呢?
在网上找了好久,有点监听软键盘事件,有点调用clearFouse()方法,但是测试了都没有!xml中也找不到相应的属性可以关闭这个默认行为
解决之道:在EditText的父级控件中找一个,设置成
| 代码如下 | 复制代码 |
|
android:focusable="true" android:focusableInTouchMode="true" | |
demo.xml:
| 代码如下 | 复制代码 |
|
android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#ffffff" android:baselineAligned="false" android:focusable="true" android:focusableInTouchMode="true"> android:layout_width="250dp" android:layout_height="wrap_content" android:id="@+id/txtLayout" android:layout_marginTop="20dp" android:layout_centerHorizontal="true" > android:layout_width="fill_parent" android:layout_height="35dp" android:id="@+id/editPhone" android:phoneNumber="true" android:text="@string/txtaddPhone" android:textColor="#D8D8D8" android:background="@drawable/txtupbg" android:textSize="15dp" /> | |
相关文章
- 塞尔达无双封印战记禁忌魔像boss战打法教学 禁忌魔像boss怎么打 12-24
- 企查查官网入口-官方正版查询入口 12-24
- 塞尔达无双封印战记武器封印解除方法 武器被封印了怎么办 12-24
- wifi万能钥匙如何轻松连接他人网络?wifi万能钥匙快速联网秘诀 12-24
- 携程官网登录入口-携程网官方网页版登录网址 12-24
- 塞尔达无双封印战记完美格挡技巧 怎么打出完美格挡 12-24