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>
  • 相关阅读:
    GET POST区别
    http1.0 1.1 2.0区别
    分布式系统理论之Quorum机制
    MySQL解析过程、执行过程
    redis常见问题和解决方案
    Windows下安装Linux虚拟机的用途和好处
    ping,telnet,ssh命令的理解
    强化学习入门 第五讲 值函数逼近
    强化学习入门第四讲 时间差分方法
    强化学习基础 第三讲 蒙特卡罗方法
  • 原文地址:https://www.cnblogs.com/tianchunming/p/5059851.html
Copyright © 2011-2022 走看看