-
Notifications
You must be signed in to change notification settings - Fork 147
Description
A false positive warning by TextContrastCheck is observed when using TextInputLayout from com.google.android.material:material. The check treats box stroke color as a foreground color. By default the box stroke color is transluscent, making it likely to trigger the warning.
Reproduction
Given a blank project from Android Studio's Empty Activity template and the following layout:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<com.google.android.material.textfield.TextInputLayout
android:padding="24dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Hello World!">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true" />
</com.google.android.material.textfield.TextInputLayout>
</FrameLayout>A warning is produced with the following output:
📝 accessibility-test-framework 4.1.1
AccessibilityViewCheckResult check=AccessibilityHierarchyCheckResult WARNING TextContrastCheck 11 [ViewHierarchyElement class=com.google.android.material.textfield.TextInputEditText bounds=Rect(0, 96 - 1080, 423)] {KEY_BACKGROUND_COLOR=-67585, KEY_CONTRAST_RATIO=4.33, KEY_FOREGROUND_COLOR=-8817538, KEY_IS_LARGE_TEXT=false, KEY_REQUIRED_CONTRAST_RATIO=4.5} num_answers:0 view=com.google.android.material.textfield.TextInputEditText{2f293a2 VFED..CL. ........ 0,0-936,167}
📝 Accessibility Scanner 2.4.1.58312255
*For some reason the share text mixes English and Dutch? 🙈 Out of scope.
Negative case
Overriding the default box stroke color with a high contrast color, the warning disappears.
| Layout | Accessibility Scanner result |
|---|---|
![]() |
![]() |


