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. 爬虫——使用ItemLoader维护item

    在item的Filed()中设置参数函数,可以用来预处理item字段的数据,另一方面也方便程序代码的管理和重用 item中 from scrapy.loader.processors import M ...

  2. springboot 2.x 集成 drools 7.x

    简介:springboot 2.0.4.RELEASE 集成 drools 7.11.0.Final 1.项目结构 2. pom.xml文件 <?xml version="1.0&qu ...

  3. G - 免费馅饼 基础DP

    都说天上不会掉馅饼,但有一天gameboy正走在回家的小径上,忽然天上掉下大把大把的馅饼.说来gameboy的人品实在是太好了,这馅饼别处都不掉,就掉落在他身旁的10米范围内.馅饼如果掉在了地上当然就 ...

  4. E - Super Jumping! Jumping! Jumping! DP

    Nowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HDU. May ...

  5. Ubuntu 16.04下使用gcc输出汇编的.0文件为可执行文件时出现:`_start'被多次定义

    错误如下: `_start'被多次定义 /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o:(.text+0x0):第一次 ...

  6. Luca Canali

    https://github.com/LucaCanali http://cern.ch/canali/

  7. ZMQ源代码分析(一)-- 基础数据结构的实现

    yqueue 和 ypipe zmq号称是"史上最快的消息队列",由此可见zmq中最重要的数据结构就是队列. zmq的队列主要由yqueue和ypipe实现.yqueue是队列的基 ...

  8. VM Workstation 虚拟机下如何安装VMtools

    不同版本Linux原理类似,这里以Debian为例. 1 根据提示点击Install Tools,CDROM中出现VmwareTools的安装包,在你的主文件夹下新建一个文件夹(随便叫什么都行,我新建 ...

  9. 还在自建Redis缓存?那你就out了

    Redis 是什么?简单来说,Redis是一个开源的内存数据库,支持Key-Value等多种数据结构,可用于缓存.事件发布或订阅.高速队列等场景.Redis使用ANSIC语言编写,支持网络,提供字符串 ...

  10. springmvc的执行流程详解

    1.什么是MVC MVC是Model View Controller的缩写,它是一个设计模式 2.springmvc执行流程详细介绍 第一步:发起请求到前端控制器(DispatcherServlet) ...