setFocusable與setFocusableInTouchMode差異以及clickable

前者針對在鍵盤下操作的情況,如果設置爲true,則鍵盤上下左右選中,焦點會隨之移動。
而後者,顯然是針對觸屏情況下的,也就是我們點擊屏幕的上的某個控件時,不要立即執行相應的點擊邏輯,而是先顯示焦點(即控件被選中),再點擊才執行邏輯。
android:focusable=“true”不會改變android:focusableInTouchMode,因此只在鍵盤狀態下顯示焦點,在TouchMode狀態下,依舊無法顯示焦點。
android:focusable=“false”,一定會使android:focusableInTouchMode=“false”。
android:focusableInTouchMode=“false”,不會影響android:focusable。
android:focusableInTouchMode=”true”,一定會是android:focusable=“true”
但請記住一點,就是對於現在觸屏時代的手機而言,如果要獲取焦點,我們只需要設置
android:foucusableInTouchMode=“true”就可以了。

發佈了20 篇原創文章 · 獲贊 10 · 訪問量 5萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章