If you disable EditText
using setEnabled(false)
, the style/color will change to light gray.
To disable EditText
(no focus and edit) wihout disabling it.
editText.isFocusable = trueeditText.isFocusableInTouchMode = trueeditText.inputType = TYPE_NULL
To enable focus and edit of EditText
.
editText.isFocusable = trueeditText.isFocusableInTouchMode = trueeditText.inputType = InputType.TYPE_CLASS_TEXT
Create an Kotlin extension
fun EditText.setReadOnly(value: Boolean, inputType: Int = InputType.TYPE_NULL) { isFocusable = !value isFocusableInTouchMode = !value this.inputType = inputType}
Else, you could show a TextView which look like EditText.