当我使用style="@style/Widget.Design.TextInputLayout"
forTextInputLayout
时,设置app:errorIconDrawable
什么也不做。它仅在我不设置样式并让它继承应用程序主题(Theme.MaterialComponents.Light.NoActionBar
)时才有效。app:endIconDrawable
也不起作用,我找不到这个问题的替代方案/解决方案。请帮忙!
继承应用程序主题时以下工作:Theme.MaterialComponents.Light.NoActionBar
但我不想要这种风格,特别是下划线与文本不对齐:
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/login_password_input_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="username"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/login_password_input_text"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.material.textfield.TextInputLayout>
这使用了我需要的样式,但不会显示错误图标:
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/login_password_input_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="username"
style="@style/Widget.Design.TextInputLayout"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/login_password_input_text"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.material.textfield.TextInputLayout>