I want to customize TextInputLayout
's error text color. My app theme is based on one of the MaterialComponents
themes namely Theme.MaterialComponents.Light.DarkActionBar
. I have created a custom text style based on TextAppearance.Design.Error
, and created a custom style based on Widget.Design.TextInputLayout
in order to set my TextInputLayout
components' styles. But the error and label of the EditText are not displayed in the created style.
Here is my code:
styles.xml
<style name="ErrorText" parent="TextAppearance.Design.Error">
<item name="android:textColor">@color/materialRed</item>
<item name="android:textSize">16sp</item>
</style>
<style name="TextInputLayoutAppearance" parent="Widget.Design.TextInputLayout">
<item name="errorTextAppearance">@style/ErrorText</item>
</style>
And, I have set my TextInputLayout
's theme to this custom style:
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/usernameWrapper"
app:errorTextAppearance="@style/TextInputLayoutAppearance"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/username"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.material.textfield.TextInputLayout>