【发布时间】:2019-09-01 17:55:42
【问题描述】:
我正在尝试将 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设为只读的正确方法或正确方法是什么?
【问题讨论】:
标签: android kotlin material-design material-components-android