在页面的开发过程中,我们可能会遇到这样的情况,打开某个页面(Activity)时,如果该页面中有EditText组建,则会自动弹出软键盘(因为该EditText自动获取焦点了),这样很容易影响用户体验; 所以,在设计页面时,我们有必要首先手动让该EditText失去焦点,这样,才可以避免软键盘弹出。

如何实现呢? 其实很简单,我们只需要让EditText的父容器获取焦点就可以了。

<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:focusable="true"
android:focusableInTouchMode="true"
android:paddingBottom="2dp"
android:paddingTop="2dp" > <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:text="用户名:"
android:textColor="#4a4a4a"
android:textSize="14sp" /> <EditText
android:id="@+id/total_price_edit"
android:layout_width="130dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:gravity="right|center_vertical"
android:inputType="numberDecimal"
android:paddingRight="6dp"
android:textColor="#ff8400"
android:textSize="23sp" >
</EditText>
</RelativeLayout>

注:

上述代码中,我们手动设置EditText的父容器RelativeLayout获取焦点:

android:focusable="true"

android:focusableInTouchMode="true"

通过这种方式,便可以很轻松的避免软键盘的弹出了

Android 隐藏EditText的焦点的更多相关文章

  1. Android - 隐藏EditText弹出的软键盘输入(SoftInput)

    隐藏EditText弹出的软键盘输入(SoftInput) 本文地址: http://blog.csdn.net/caroline_wendy 保持界面的整洁, 能够选择在进入界面时, 隐藏EditT ...

  2. android隐藏EditText光标

    在android中如果有EditText,那么在载入时,光标会默认显示在第一个EditText框中,如果不想显示光标,且也不想把该光标移动到下一个EditText框,最简单的方法是在该 EditTex ...

  3. 键盘--android 隐藏系统键盘

    . -----------------------------------------已验证----------------------------------- public static void ...

  4. android 隐藏系统键盘

    -----------------------------------------已验证----------------------------------- public static void c ...

  5. Android中Edittext的属性

    //此为转载别人的,挺不错的 1.EditText输入的文字为密码形式的设置 (1)通过.xml里设置: 把该EditText设为:android:password="true"  ...

  6. Android中EditText显示明文与密文的两种方式

    版权声明:本文为HaiyuKing原创文章,转载请注明出处! 前言 记录输入框显示.隐藏密码的简单布局以及实现方式. 效果图    代码分析 方式一 /**方式一:*/ private void sh ...

  7. Android 自定义EditText实现类iOS风格搜索框

    最近在项目中有使用到搜索框的地方,由于其样式要求与iOS的UISearchBar的风格一致.默认情况下,搜索图标和文字是居中的,在获取焦点的时候,图标和文字左移.但是在Android是并没有这样的控件 ...

  8. Android 禁止Edittext弹出系统软键盘 的几种方法

    第一种方法:在XML文件下添加: android:focusable="true" android:focusableInTouchMode="true" 第二 ...

  9. Android开发 EditText的开发记录

    设置显示内容与隐藏内容 if (isChecked){ editPassword.setTransformationMethod(HideReturnsTransformationMethod.get ...

随机推荐

  1. SASS:sass语法参照列表及教程

    http://sass-lang.com/documentation/file.SASS_REFERENCE.html 保存一下,上面的链接包括了scss中所有语法规则. 转载自:http://www ...

  2. 如何制作可以在 MaxCompute 上使用的 crcmod

    之前我们介绍过在 PyODPS DataFrame 中使用三方包.对于二进制包而言,MaxCompute 要求使用包名包含 cp27-cp27m 的 Wheel 包.但对于部分长时间未更新的包,例如 ...

  3. 【python之路21】用户登陆程序函数

    一.用户登陆函数实例 1.注意:以后写函数时必须在函数第一行后按回车加入“”““”“””两对三引号后回车,此时会自动列出参数值,注释函数的作用.参数的用法和返回值 #!usr/bin/env pyth ...

  4. Leetcode876.Middle of the Linked List链表的中间节点

    给定一个带有头结点 head 的非空单链表,返回链表的中间结点. 如果有两个中间结点,则返回第二个中间结点. 示例 1: 输入:[1,2,3,4,5] 输出:此列表中的结点 3 (序列化形式:[3,4 ...

  5. Linux常用命令2 权限管理命令

    1.权限管理命令:chmod 上面图片中的ugoa与rwx并不是一个命令,而是不同选项 u 所有者  g 所属组 o 其他人 a 所有人 r 读取权限 w写入权限  x 执行权限 chmod u+x ...

  6. VUE中的style 样式处理的Scope (<style scope>)

    在VUE组件中,为了让样式私有化,不对全局造成污染,可以在style标签上添加scoped属性以表示它的只属于当下的模块. 但是这样的话,就会导致无法修改其他第三方组件样式,或者是内嵌的样式,解决方案 ...

  7. Mac下搭建python开发环境

    目录 1. 安装brew 2. 安装 mysql 3. 安装 pycharm 4. 安装python3.6 5. 安装virtualenvwrapper 6. 虚拟环境下安装mysqlclient 1 ...

  8. LeetCode225 Implement Stack using Queues

    Implement the following operations of a stack using queues. (Easy) push(x) -- Push element x onto st ...

  9. Flask 第二篇

    Flask 中的 Render Redirect HttpResponse 1.Flask中的HTTPResponse 在Flask 中的HttpResponse 在我们看来其实就是直接返回字符串 2 ...

  10. Hbuilder的使用技巧

    /*注:本教程针对HBuilder5.0.0,制作日期2014-12-31*/创建HTML结构: h 8 (敲h激活代码块列表,按8选择第8个项目,即HTML代码块,或者敲h t Enter)中途换行 ...