zoukankan      html  css  js  c++  java
  • 设置Android让EditText不自动获取焦点

    最近在做一个练手项目的时候,因为默认进入的页面有一个EditText控件,每次进入的时候会自动获取焦点弹出软键盘,体验非常不好,后来在网上找到了解决办法:在EditText的父级控件中找到以下属性,设置成

       android:focusable="true"  
       android:focusableInTouchMode="true"

    这样,就把EditText默认的行为截断了!

     1   <LinearLayout
     2                     android:id="@+id/ly_express_number"
     3                     android:layout_width="fill_parent"
     4                     android:layout_height="wrap_content"
     5                     android:layout_below="@id/tv_field_number"
     6                     android:layout_marginLeft="5.0dip"
     7                     android:layout_toRightOf="@id/iv_barcode"
     8                     android:focusable="true"
     9                     android:focusableInTouchMode="true"
    10                     android:gravity="center_vertical"
    11                     android:orientation="horizontal" >
    12 
    13                     <EditText
    14                         android:id="@+id/et_express_number"
    15                         android:layout_width="0.0dip"
    16                         android:layout_height="wrap_content"
    17                         android:layout_weight="1.0"
    18                         android:background="@null"
    19                         android:gravity="center_vertical"
    20                         android:hint="@string/plz_input_ed_number"
    21                         android:inputType="text"
    22                         android:padding="3.0dip"
    23                         android:singleLine="true" >
    24                     </EditText>
    25 
    26                     <ImageView
    27                         android:id="@+id/iv_number_clear"
    28                         android:layout_width="20.0dip"
    29                         android:layout_height="20.0dip"
    30                         android:layout_alignBottom="@id/et_express_number"
    31                         android:src="@drawable/img_close_pressed_2"
    32                         android:visibility="gone" />
    33 
    34                     <ImageView
    35                         android:id="@+id/iv_open_camera"
    36                         android:layout_width="50dp"
    37                         android:layout_height="wrap_content"
    38                         android:src="@drawable/btn_camera" />
    39                 </LinearLayout>
  • 相关阅读:
    JBoss下配置数据源加密
    线程返回值的方式介绍
    @Async java 异步方法
    spring 源码下载地址
    springmvc maven 入门及页面拿不到controller的值 显示${message} el表达式不起作用
    mysql常用函数
    eclipse 开发常见问题集锦
    linux 常用命令及零散知识
    js一些注意事项
    liunx 免密登录远程主机
  • 原文地址:https://www.cnblogs.com/tianchunming/p/5059851.html
Copyright © 2011-2022 走看看