Android 第一次點擊EditText不顯示光標問題

可以考慮在 XML 佈局文件中添加 android:focusableInTouchMode="true" 屬性,以確保 ClearEditText 控件在觸摸模式下也能獲取焦點。這樣,用戶在首次點擊時會立即看到光標。

在 XML 佈局文件中,將 ClearEditText 的定義中添加 android:focusableInTouchMode 屬性,如下所示:

<com.tools.qrtestassist.component.ClearEditText
    android:id="@+id/your_edittext_id"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:focusable="true"
    android:focusableInTouchMode="true"
    android:hint="Your Hint"
    android:inputType="text"
    android:maxLength="10"
    android:layout_marginBottom="16dp" />

這將確保 ClearEditText 在觸摸模式下立即獲取焦點,用戶點擊時會看到光標。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章