我正在尝试将TextInputEditText设置为只读,但会快速闪现光标并触发点击事件。
我尝试设置isFocusable=false
和isClickable=false
。
XML布局:
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/label_address"
android:layout_marginTop="@dimen/material_layout_vertical_spacing_between_content_areas"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/input_address"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionNext"/>
</com.google.android.material.textfield.TextInputLayout>
代码使其只读:
fun TextInputEditText.disable() {
isFocusable = false
isClickable = false
}
如何正确地或者说适当地使TextInputEditText变为只读模式?