【发布时间】:2019-04-06 08:28:00
【问题描述】:
我有一个带有两个文本输入字段的布局,它们会随着选项的变化而消失并重新出现。
但是,当我使用属性 app:endIconMode="clear_text" 时,这两个警告会在两个文本字段中无休止地淹没日志。
W/View:requestLayout() 被不正确地调用 com.google.android.material.textfield.TextInputEditText{ba3099c VFED..CL。 ......ID 0,0-1244,272 #7f0a00c6 app:id/homeInput} 期间 布局:运行第二个布局通道
W/View:requestLayout() 被不正确地调用 com.google.android.material.textfield.TextInputEditText{f641714 VFED..CL。 ......ID 0,0-1244,224 #7f0a00e6 app:id/lockInput} 期间 布局:运行第二个布局通道
可见的文本字段取决于RadioButton 选择
其中一个文本字段 XML 的片段:
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/alt_sub"
style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="24dp"
android:layout_marginEnd="40dp"
android:animateLayoutChanges="true"
app:boxCornerRadiusTopEnd="8dp"
app:boxCornerRadiusTopStart="8dp"
app:boxStrokeColor="@color/colorAccent"
app:endIconMode="clear_text"
app:hintTextColor="@color/colorAccent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/main_sub">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/lockInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_+"
android:fontFamily="@font/opensansregular"
android:inputType="textNoSuggestions" />
</com.google.android.material.textfield.TextInputLayout>
每当我在 Activity 类中调用setText() 或setHint() 时,就会开始弹出警告。警告仅在文本字段为空时停止。
我觉得这可能与属性app:endIconMode="clear_text"有关,但是我找不到使用它的方法而不收到这些警告。
【问题讨论】: