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失去焦点并禁止弹出键盘的更多相关文章

  1. 《笔记篇》非JS方法跳转到一个新页面,主要防止客户端禁止浏览器JS以后的跳转异常

    用非JS方法打开一个新页面,主要防止客户端禁止浏览器JS以后的跳转失效 <meta http-equiv="refresh" content="0; url=htt ...

  2. Android中使EditText失去焦点,edittext禁止弹出键盘[转]

    转自http://www.cnblogs.com/yejiurui/archive/2013/01/02/2841945.html 在我们的应用中,有时候一进入一个页面, EditText默认就会自动 ...

  3. :input获得焦点时被弹出键盘挡住解决办法

    这个是移动端非常常见的bug了,这里说下综合的解决办法,因为有时候你的办法就是会失效.. 上代码 /*input框调起输入法盖住输入问题*/$('input[type="text" ...

  4. IPhone手机页面中点击文本输入框,弹出键盘,网页会放大,如何解决

    在head标签中加入以上meta声明.具体属性可以谷歌/百度. <meta name="viewport" content="width=device-width, ...

  5. 直接提交一个form表单后台返回一个新页面通过target属性可以放到iframe当中

    问题描述: 我想提交一个form表单后台直接返回一个新页面,但是当前页面还不想被替换掉: 解决方案: 在页面中添加一个iframe将form表单的target属性设置为iframe的id这样的话返回的 ...

  6. selenium获取新页面标签页(只弹出一个新页面的切换)

    selenium获取新页面标签页(只弹出一个新页面的切换) windows = driver.current_window_handle #定位当前页面句柄 all_handles = driver. ...

  7. PHP——0128练习相关2——js点击button按钮跳转到另一个新页面

    js点击button按钮跳转到另一个新页面 投稿:whsnow 字体:[增加 减小] 类型:转载 时间:2014-10-10我要评论 点击按钮怎么跳转到另外一个页面呢?点击图片要跳转到新的页面时,怎么 ...

  8. android 创建一个新的每次project什么时候 请问自己主动 参加 V7依赖?

    android 创建一个新的每次project什么时候 请问自己主动 参加 V7依赖? 分析原因: 主要是由于.我之前的 SDK 的版本号 更新的有点高了.低版本号是不会有这样的问题g的,新版本号中g ...

  9. JS解析Json 数据并跳转到一个新页面,取消A 标签跳转

    JS解析Json 数据并跳转到一个新页面,代码如下 $.getJSON("http://api.cn.abb.com/common/api/staff/employee/" + o ...

随机推荐

  1. Win32编程API 基础篇 -- 1.入门指南 根据英文教程翻译

    入门指南 本教程是关于什么的 本教程的目的是向你介绍使用win32 API编写程序的基础知识(和通用的写法).使用的语言是C,但大多数C++编译器也能成功编译,事实上,教程中的绝大多数内容都适用于任何 ...

  2. 常见的HTTP状态码(HTTP Status Code)

    HTTP状态码 当使用浏览器访问一个网页时,浏览器会向网页所在服务器发出请求.当浏览器接收并显示网页前,此网页所在的服务器会返回一个包含HTTP状态码的信息头(server header)用以响应浏览 ...

  3. Spring mvc+Easyui遇到的几个问题

    简单的一个数据表的增删查改的总体界面的展示效果例如以下图: 1.datagrid数据载入问题 datagrid通过url请求后台数据,总记录数和数据行的属性是固定死的.数据行是rows,总记录数为to ...

  4. MapR CEO对2016大数据的5个预測

    本文来源于我在InfoQ中文站翻译的文章,原文地址是:http://www.infoq.com/cn/news/2016/02/mapr-ceo-5-big-data-predictions MapR ...

  5. Spark SQL CLI 实现分析

    背景 本文主要介绍了Spark SQL里眼下的CLI实现,代码之后肯定会有不少变动,所以我关注的是比較核心的逻辑.主要是对照了Hive CLI的实现方式,比較Spark SQL在哪块地方做了改动,哪些 ...

  6. j2se回想

    执行Java程序. Java程序有两种方式一种是jar包.一种是class. 执行jar,Java -jar XXX.jar执行的时候,Java.exe调用GetMainClassName函数,该函数 ...

  7. ios測试的时候出现错误

    dyld: Library not loaded: @rpath/XCTest.framework/XCTest   Referenced from: /Users/zhumin/Library/De ...

  8. 【Android】资源系列(一) -- 国际化(多语言)

    1.Android 中要实现国际化比較简单.     字符串国际化:仅仅要在 res 目录下新建相应语言的 values 目录就好了.     如.英语环境下的.目录命名为:values-en     ...

  9. Linux下的画图软件

    Pinta是一款和windows下的画图相类似打一款画图软件,并且它还包含了一些基本的图像编辑工具. 比如:标尺.图层.操作历史记录.图像调整.渲染效果等等,可以满足对图像处理要求不太高的用户的基本需 ...

  10. vs2008C1902程序数据库管理不匹配

    大清早打开vs2008,出现这么诡异的错, 删了一个dll的就好了.如图