我试图将TextInputEditText设为只读,但光标快速闪烁,点击被触发.
I tried setting isFocusable = false
and 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>
Code to make read-only:
fun TextInputEditText.disable() {
isFocusable = false
isClickable = false
}
什么是使TextInputItemText只读的正确方法?