【问题标题】:Android TextInputEditText flooding logs with requestLayout() warnings when using endIconMode attribute使用 endIconMode 属性时带有 requestLayout() 警告的 Android TextInputEditText 泛滥日志
【发布时间】: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"有关,但是我找不到使用它的方法而不收到这些警告。

【问题讨论】:

    标签: java android


    【解决方案1】:

    我在使用不同的 endIconModes 时遇到了同样的问题,但在互联网上没有找到任何解决方案,所以我用谷歌打开了一个缺陷: https://issuetracker.google.com/issues/132651327

    该问题今天已修复,本周发布时应该可以在 com.google.android.material v1.1.0-alpha07 中正常使用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-03-10
      • 2017-05-11
      • 2017-12-24
      • 2017-06-26
      • 1970-01-01
      • 2021-06-02
      • 2013-02-25
      相关资源
      最近更新 更多