How to set TextInputLayout error message colour?
Create a custom style which uses @android:style/TextAppearance
as parent in your styles.xml
file:
<style name="error_appearance" parent="@android:style/TextAppearance">
<item name="android:textColor">@color/red_500</item>
<item name="android:textSize">12sp</item>
</style>
And use it in your TextInputLayout widget:
<android.support.design.widget.TextInputLayout
android:id="@+id/emailInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:errorTextAppearance="@style/error_appearance">
Edit: Set the hint on the object, which is inside your TextInputLayout (EditText
, TextView
, etc.) to hold different colors for the hint and the error.
How to change underline color error textinputlayout android
Just use the app:boxStrokeErrorColor
attribute:
<com.google.android.material.textfield.TextInputLayout
app:boxStrokeErrorColor="@color/primaryLightColor"
...>
It requires Material Components lirabry version 1.2.0
.
TextInputLayout default error color on Android
The only solution I found was to check the code of TextInputLayout.
I found that the style is
<style name="TextAppearance.Design.Error" parent="TextAppearance.AppCompat.Caption">
<item name="android:textColor">@color/design_textinput_error_color</item>
</style>
where
<color name="design_textinput_error_color">#FFDD2C00</color>
but it seems this is not documented so it can change
How to know what is color of TextInputLayout error in Android?
The default error color is based on the colorError
attribute.
The current value in a light theme is:
<color name="design_default_color_error">#B00020</color>
If you want to use it in another attribute you can copy this value or you can use ?attr/colorError
. Example:
<item name="strokeColor">?attr/colorError</item>
If you want to get programmatically this value you can use:
MaterialColors.getColor(fab, R.attr.colorError)
Related Topics
Programmatically Adding Tablerow to Tablelayout Not Working
Simple Example for Intent and Bundle
How to Set Textinputlayout Error Message Colour
How to Sync SQLite Database on Android Phone with MySQL Database on Server
Uploading a Large File in Multipart Using Okhttp
Check Whether the Sd Card Is Available or Not Programmatically
Converting Bitmap to Bytearray Android
Using Picasso with Custom Disk Cache
Android: How to Get Value of an Attribute in Code
Forcing the Soft Keyboard Open
How to Prevent an Application from Being Uninstalled
Android\Intent: Send an Email with Image Attachment
Register Application Class in Manifest
How to Get All Checked Items from a Listview