【发布时间】:2019-11-23 10:35:07
【问题描述】:
如何将TextInputLayout 设置为只读?
我的代码如下图:
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/TextInputLayout_fromAddAbsenceBottomSheet_AbsenceTaken"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:hint="Absence Taken"
app:helperText="* Optional"
app:layout_constraintEnd_toEndOf="@+id/TextInputLayout_fromAddAbsenceBottomSheet_AbsenceGiven"
app:layout_constraintStart_toStartOf="@+id/TextInputLayout_fromAddAbsenceBottomSheet_AbsenceGiven"
app:layout_constraintTop_toBottomOf="@+id/TextInputLayout_fromAddAbsenceBottomSheet_AbsenceGiven"
style="@style/Widget.Unify.TextInputLayout">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/TextField_fromAddAbsenceBottomSheet_AbsenceTaken"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
style="@style/Widget.Unify.EditText"/>
</com.google.android.material.textfield.TextInputLayout>
我需要将TextInputLayout 设为只读而不是EditText。
我需要在TextInputLayout 级别将其设为只读,因为我需要对其应用样式。
我已经在TextInputLayout 中尝试过android:enabled="false",但它仍然可以让我更改文本。
【问题讨论】:
-
仅对 TextInputLayout 意味着什么?我不清楚。您需要风格级别的东西吗?
标签: android android-styles android-textinputlayout material-components material-components-android