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. SGU 485 Arrays

    485. Arrays Time limit per test: 1.75 second(s)Memory limit: 262144 kilobytes input: standardoutput: ...

  2. HDU RSA 扩展欧几里得

    Problem Description RSA is one of the most powerful methods to encrypt data. The RSA algorithm is de ...

  3. Python基础--高速改造:字符串

    Python的字符串值得一说. 先看: >>>"Hello world!" 'Hello world!' 我们写是双引號,可是打印出来后是单引號. 差别何在? 答 ...

  4. UVA 10385 - Duathlon(三分法)

    UVA 10385 - Duathlon 题目链接 题意:一些运动员,參加铁人两项,跑步r千米,骑车k千米,如今知道每一个人的跑步和骑车速度,问是否能设置一个r和k,保持r + k = t,使得第n个 ...

  5. 改动grub默认启动顺序

    grub如今有两个版本号,一个grub,一个grub2,两个版本号的操作不太一样. 装centos的朋友非常有可能是grub.我电脑装的是ubuntu14.04,为grub2.我演示grub2的过程. ...

  6. Chrome 消息机制

    Chrome浏览器扩展开发系列之十四:本地消息机制Native messaging 时间:2015-10-08 16:17:59      阅读:1560      评论:0      收藏:0    ...

  7. 自己动手写reg注册表文件

    自己动手写reg注册表文件 2015-01-12 20:23 1161人阅读 评论(1) 收藏 举报  分类: 玩转Windows应用层编程(12)  版权声明:本文为博主原创文章,未经博主允许不得转 ...

  8. zoj3605 Find the Marble --- 概率dp

    n个杯子.球最開始在s位置.有m次换球操作,看到了k次,看的人依据自己看到的k次猜球终于在哪个位置,输出可能性最大的位置. dp[m][k][s]表示前m次操作中看到了k次球终于在s的频率. #inc ...

  9. LeetCode 387. First Unique Character in a String (字符串中的第一个唯一字符)

    题目标签:String, HashMap 题目给了我们一个 string,让我们找出 第一个 唯一的 char. 设立一个 hashmap,把 char 当作 key,char 的index 当作va ...

  10. 3301 Square words

    3301 Square words  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 钻石 Diamond 题解  查看运行结果     题目描述 Description 定义s ...