Android进入一个新页面,EditText失去焦点并禁止弹出键盘
android在进入一个新页面后,edittext会自动获取焦点并弹出软键盘,这样并不符合用户操作习惯。
在其父控件下,添加如下的属性,就可以完美解决,使其进入页面后不主动获取焦点,并且不弹出软键盘:
android:focusable="true"
android:focusableInTouchMode="true"
代码如下:
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"> <LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="vertical">
<!--表单-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="vertical"> <View
android:layout_width="match_parent"
android:layout_height="14dp"
android:background="@color/stroke_color" /> <View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/stroke_color" /> <TextView
android:id="@+id/tv_title_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="18dp"
android:layout_marginLeft="21dp"
android:layout_marginTop="18dp"
android:text="@string/title_coming_menu"
android:textColor="@color/font_dark_gray"
android:textSize="18sp" /> <View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/stroke_color" /> <LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"> <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"> <RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"> <TextView
android:id="@+id/FromMessage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginLeft="21dp"
android:layout_marginTop="21dp"
android:text="@string/title_coming_unit"
android:textColor="@color/font_gray"
android:textSize="16sp" /> <TextView
android:id="@+id/txtFromMessage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/FromMessage"
android:layout_toRightOf="@+id/FromMessage"
android:textColor="@color/activity_dark3"
android:textSize="16sp" />
</RelativeLayout> <TextView
android:layout_width="1px"
android:layout_height="match_parent"
android:layout_marginTop="13dp"
android:background="@color/plan_detail_line" /> <RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"> <TextView
android:id="@+id/FromMessageNo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginLeft="17dp"
android:layout_marginTop="21dp"
android:text="@string/title_coming_number"
android:textColor="@color/font_gray"
android:textSize="16sp" /> <TextView
android:id="@+id/txtFromMessageNo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/FromMessageNo"
android:layout_toRightOf="@id/FromMessageNo"
android:textColor="@color/activity_dark3"
android:textSize="16sp" />
</RelativeLayout>
</LinearLayout> <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"> <RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_weight="1"> <TextView
android:id="@+id/Signer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginLeft="21dp"
android:text="@string/title_coming_signer"
android:textColor="@color/font_gray"
android:textSize="16sp" /> <TextView
android:id="@+id/txtSigner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/Signer"
android:layout_toRightOf="@+id/Signer"
android:textColor="@color/activity_dark3"
android:textSize="16sp" />
</RelativeLayout> <TextView
android:layout_width="1px"
android:layout_height="match_parent"
android:background="@color/plan_detail_line" /> <RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_weight="1"> <TextView
android:id="@+id/FilePriorities"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginLeft="17dp"
android:text="@string/title_coming_priority"
android:textColor="@color/font_gray"
android:textSize="16sp" /> <TextView
android:id="@+id/txtFilePriorities"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/FilePriorities"
android:layout_toRightOf="@+id/FilePriorities"
android:textColor="@color/activity_dark3"
android:textSize="16sp" />
</RelativeLayout>
</LinearLayout> <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"> <RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"> <TextView
android:id="@+id/ReceiptNumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="21dp"
android:layout_marginLeft="21dp"
android:text="@string/title_coming_identifier"
android:textColor="@color/font_gray"
android:textSize="16sp" /> <TextView
android:id="@+id/txtReceiptNumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/ReceiptNumber"
android:layout_toRightOf="@+id/ReceiptNumber"
android:textColor="@color/activity_dark3"
android:textSize="16sp" />
</RelativeLayout> <TextView
android:layout_width="1px"
android:layout_height="match_parent"
android:layout_marginBottom="13dp"
android:background="@color/plan_detail_line" /> <RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout> <View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/stroke_color" /> <View
android:layout_width="match_parent"
android:layout_height="14dp"
android:background="@color/stroke_color" /> <View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/stroke_color" />
</LinearLayout> <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="vertical"> <View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/stroke_color" /> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="18dp"
android:layout_marginLeft="21dp"
android:layout_marginTop="18dp"
android:text="@string/title_signfor_branch"
android:textColor="@color/font_dark_gray"
android:textSize="18sp" /> <View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/stroke_color" /> <RelativeLayout
android:id="@+id/rlFileType"
android:layout_width="match_parent"
android:layout_height="wrap_content"> <TextView
android:id="@+id/txtFileType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="18dp"
android:layout_marginLeft="21dp"
android:layout_marginTop="24dp"
android:text="@string/title_file_type"
android:textColor="@color/font_gray"
android:textSize="16sp" /> <RadioGroup
android:id="@+id/rgFileType"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="19dp"
android:layout_toRightOf="@+id/txtFileType"
android:checkedButton="@+id/rbDoArticle"
android:orientation="horizontal"> <RadioButton
android:id="@+id/rbDoArticle"
style="@style/FileTypeRadioButtonNew"
android:text="@string/title_fileType_branch" /> <RadioButton
android:id="@+id/rbReadPiece"
style="@style/FileTypeRadioButtonNew"
android:layout_marginLeft="20dp"
android:text="@string/title_fileType_read_piece" /> <RadioButton
android:id="@+id/rbTelegram"
style="@style/FileTypeRadioButtonNew"
android:layout_marginLeft="20dp"
android:text="@string/title_fileType_telegram" /> <RadioButton
android:id="@+id/rbElse"
style="@style/FileTypeRadioButtonNew"
android:layout_marginLeft="20dp"
android:text="@string/title_fileType_another" />
</RadioGroup>
</RelativeLayout> <RelativeLayout
android:id="@+id/rlPoints"
android:layout_width="match_parent"
android:layout_height="wrap_content"> <TextView
android:id="@+id/Points"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="21dp"
android:layout_marginTop="18dp"
android:text="@string/title_branch_department"
android:textColor="@color/font_gray"
android:textSize="16sp" /> <TextView
android:id="@+id/txtPoints"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_toRightOf="@+id/Points"
android:background="@drawable/shape_tv_signfor_pointfor"
android:paddingBottom="3dp"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:paddingTop="3dp"
android:text="@string/content_pointfor"
android:textColor="@color/flowmsg_doing" />
</RelativeLayout> <RelativeLayout
android:id="@+id/rlOpinion"
android:layout_width="match_parent"
android:layout_height="wrap_content"> <TextView
android:id="@+id/Opinion"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="21dp"
android:layout_marginTop="18dp"
android:text="@string/title_branch_advice"
android:textColor="@color/font_gray"
android:textSize="16sp" /> <EditText
android:id="@+id/txtOpinion"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_marginRight="20dp"
android:layout_marginTop="19dp"
android:layout_toRightOf="@+id/Opinion"
android:background="@drawable/shape_et_bg"
android:gravity="top"
android:hint="@string/hint_write_branch_advice"
android:padding="9dp"
android:textColor="@color/tab_text"
android:textSize="14sp" />
</RelativeLayout> <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="40dp"
android:layout_marginTop="40dp"
android:gravity="center"> <Button
android:id="@+id/tv_sign_for"
android:layout_width="250dp"
android:layout_height="50dp"
android:background="@drawable/selector_btn"
android:text="@string/btn_signfor_branch"
android:textAppearance="@style/common_text_size"
android:textColor="@color/white" /> <Button
android:id="@+id/tv_retreat"
android:layout_width="250dp"
android:layout_height="50dp"
android:layout_marginLeft="40dp"
android:background="@drawable/selector_btn_3"
android:text="@string/btn_retreat"
android:textAppearance="@style/common_text_size"
android:textColor="@color/flowmsg_doing" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
不一定只加在父级布局中,如果没有效果,可以试试更高级的父级布局中,就像示例代码中展示的一样,写在scrollview下面的布局之中。
Android进入一个新页面,EditText失去焦点并禁止弹出键盘的更多相关文章
- 《笔记篇》非JS方法跳转到一个新页面,主要防止客户端禁止浏览器JS以后的跳转异常
用非JS方法打开一个新页面,主要防止客户端禁止浏览器JS以后的跳转失效 <meta http-equiv="refresh" content="0; url=htt ...
- Android中使EditText失去焦点,edittext禁止弹出键盘[转]
转自http://www.cnblogs.com/yejiurui/archive/2013/01/02/2841945.html 在我们的应用中,有时候一进入一个页面, EditText默认就会自动 ...
- :input获得焦点时被弹出键盘挡住解决办法
这个是移动端非常常见的bug了,这里说下综合的解决办法,因为有时候你的办法就是会失效.. 上代码 /*input框调起输入法盖住输入问题*/$('input[type="text" ...
- IPhone手机页面中点击文本输入框,弹出键盘,网页会放大,如何解决
在head标签中加入以上meta声明.具体属性可以谷歌/百度. <meta name="viewport" content="width=device-width, ...
- 直接提交一个form表单后台返回一个新页面通过target属性可以放到iframe当中
问题描述: 我想提交一个form表单后台直接返回一个新页面,但是当前页面还不想被替换掉: 解决方案: 在页面中添加一个iframe将form表单的target属性设置为iframe的id这样的话返回的 ...
- selenium获取新页面标签页(只弹出一个新页面的切换)
selenium获取新页面标签页(只弹出一个新页面的切换) windows = driver.current_window_handle #定位当前页面句柄 all_handles = driver. ...
- PHP——0128练习相关2——js点击button按钮跳转到另一个新页面
js点击button按钮跳转到另一个新页面 投稿:whsnow 字体:[增加 减小] 类型:转载 时间:2014-10-10我要评论 点击按钮怎么跳转到另外一个页面呢?点击图片要跳转到新的页面时,怎么 ...
- android 创建一个新的每次project什么时候 请问自己主动 参加 V7依赖?
android 创建一个新的每次project什么时候 请问自己主动 参加 V7依赖? 分析原因: 主要是由于.我之前的 SDK 的版本号 更新的有点高了.低版本号是不会有这样的问题g的,新版本号中g ...
- JS解析Json 数据并跳转到一个新页面,取消A 标签跳转
JS解析Json 数据并跳转到一个新页面,代码如下 $.getJSON("http://api.cn.abb.com/common/api/staff/employee/" + o ...
随机推荐
- Uva10562
Professor Homer has been reported missing. We suspect that his recent research works might have had ...
- poj 2823单调队列模板题
#include<stdio.h>//每次要吧生命值长的加入,吧生命用光的舍弃 #define N 1100000 int getmin[N],getmax[N],num[N],n,k, ...
- java 源码分析1 -String
1. String的本质是一个 char数组,实现了CharSequence 接口, /** The value is used for character storage. */ private f ...
- 试来试去,WIN下最简单的WIN API开发工具,Pelles C就好啦
昨晚试过N个,不是太大,就是不容易和WIN API集成. 今早一试就灵了个.... Pelles C. Pelles C是一款windows下的C IDE,支持调试,且为免费.它有一个高效率的链接器, ...
- JavaSE部分之(1)Java基础
JavaSE部分之(1)Java基础 1.为什么重写equals还要重写hashcode 为了提高程序的效率才实现了hashcode方法,先进行hashcode的比较,如果不同,那就没必要再进行equ ...
- 编译Linux使用的.a库文件
编译Linux使用的.a库文件 首先是须要编译成.a的源文件 hello.h: #ifndef __INCLUDE_HELLO_H__ #define __INCLUDE_HELLO_H__ void ...
- FTP用户-禁止登录系统
OS是Ubuntu 11.10. 1. which nologin #/usr/sbin/nologin 2. vim /etc/shells #在该文件后添加/usr/sbin/nolo ...
- License使用成本估算
License使用成本估算 Licmanager系统的成本估算模块是以參数估算法为基础的计算机成本估算软件,内部包括多个成本估算关系式,综合反映了license的使用特征.产品项目特征以组织经济环境等 ...
- 大话USB驱动之总线驱动程序
转载注明出处:http://blog.csdn.net/ruoyunliufeng/article/details/25040009 总线驱动是不用改的.内核都帮我们做好了.为了了解整个USB驱动的体 ...
- Ajax异步方式实现登录与參数的校验
登录代码 这个是使用Bootstrap3的组件功能实现的 <div class="login_con_R"> <h4>登录</h4> <F ...