設定Android讓EditText不自動擷取焦點

來源:互聯網
上載者:User

標籤:

最近在做一個練手項目的時候,因為預設進入的頁面有一個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                     <EditText14                         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                     <ImageView27                         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                     <ImageView35                         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>

 

設定Android讓EditText不自動擷取焦點

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.