Phi*_*bon 9 android kotlin material-design material-components-android
我正在尝试将 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>
Run Code Online (Sandbox Code Playgroud)
使只读的代码:
fun TextInputEditText.disable() {
isFocusable = false
isClickable = false
}
Run Code Online (Sandbox Code Playgroud)
使 TextInputEditText 只读的正确方法或正确方法是什么?
套装属性android:enable="false"中TextInputEditText
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Hints"
android:layout_marginTop="10dp"
android:layout_margin="40dp">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/input_address"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:enabled="false"
android:imeOptions="actionNext"
android:text="Hi How are you"
android:textColor="@color/colorPrimary"
android:textColorHint="@color/colorPrimary" />
</com.google.android.material.textfield.TextInputLayout>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6691 次 |
| 最近记录: |