日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > Android >内容正文

Android

Android取消EditText自动获取焦点默认行为

發布時間:2025/3/20 Android 40 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Android取消EditText自动获取焦点默认行为 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

在項目中,有時候想要編輯框開始不獲取焦點,當點擊編輯框獲得焦點時,會調到下一個Activity中。

一般情況下,一進入一個頁面, EditText默認就會自動獲取焦點。

解決之道:在EditText的父級控件中找一個,添加這兩個屬性:

android:focusable="true" android:focusableInTouchMode="true" 這樣,就把EditText默認的行為截斷了!
?例如:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent" android:focusable="true"android:focusableInTouchMode="true"><!-- 這兩句是為了取消自動獲取焦點 --><com.baidu.mapapi.map.MapViewandroid:id="@+id/id_bmapView"android:layout_width="fill_parent"android:layout_height="fill_parent"android:clickable="true" /><EditTextandroid:id="@+id/search_edittext"android:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_marginTop="15dp"android:background="@drawable/search_bar_edit_bg"android:drawableLeft="@drawable/search_bar_icon_normal"android:hint="搜索"android:selectAllOnFocus="true"android:singleLine="true"android:textColor="#000" ></EditText><Buttonandroid:id="@+id/button_selector"android:layout_width="40dp"android:layout_height="40dp"android:layout_alignParentRight="true"android:layout_alignParentTop="true"android:layout_marginRight="25dp"android:layout_marginTop="100dip"android:background="@drawable/mmm" /><Buttonandroid:id="@+id/traffic"android:layout_width="40dp"android:layout_height="40dp"android:layout_alignLeft="@+id/button_selector"android:layout_below="@+id/button_selector"android:layout_marginTop="15dp"android:background="@drawable/traffic" /></RelativeLayout>

總結

以上是生活随笔為你收集整理的Android取消EditText自动获取焦点默认行为的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。