I got a "Insufficient text color contrast ratio" warning in my layout. When I used the "Fix" option in the warning screen, it added an attribute android:hintTextColor
to my text view in the xml file.
When I built the project, I got an error saying that the above attribute was not found. When I searched through all the attributes for the TextView
, the most similar attribute I could find is textColorHint
.
Is this a bug in Android Studio? Or did I get something wrong?
Thanks
3
Answers
This warning does not require any Attribute to be added, all you need to do is to enhance the contrast between the text and the background.
e.g. Set font to white if your background is black
If there is no improvement, you can try to use less complicated patterns as background.
Use
android:background="@color/white"
andandroid:textColorHint="@color/white"
in TextInputEditText and the warning will be gone. see below how I used it.Edit: As the above code will hide InputLayout border to avoid that set you parent view color to white see the below code.
You just go to this type of side website for a color contrast ratio calculator. Like
https://coolors.co/contrast-checker/ffffff-006fe6
Now, input your text color and background color. Then Click on to Enhance Button. You can adjust the text color, background color, or both colors. Maybe it will help you. Thanks