Accessibility Check fail when using TextInputLayout

后端 未结 4 1321
Happy的楠姐
Happy的楠姐 2021-01-12 02:32

I\'m using the new TextInputLayout provided by Android.support to do floating label. But it will fail Espresso Accessibility Check because \"View is missing speakable text n

4条回答
  •  感情败类
    2021-01-12 03:02

    Alternatively, if this is a false positive you can ignore checks as described here

    val validator: AccessibilityValidator = AccessibilityChecks.enable().apply {
    setSuppressingResultMatcher(
            allOf(
                    matchesCheckNames(`is`("TouchTargetSizeViewCheck")),
                    matchesViews(withId(R.id.my_overflow))
            )
    )}
    

    The following rules are invoked when we enable tests for accessibility checks:

    • TouchTargetSizeViewCheck Target height or target width less than 48 dp is flagged, unless there is a touchdelegate detected.
    • TextContrastViewCheck Checks text color and background and factors in large text, and calculates the contrast ratio: - 4.5 for regular text, 3 for large text.
    • DuplicateSpeakableTextViewHierarchyCheck If two Views in a hierarchy have the same speakable text, that could be confusing for users if at least one of them is clickable.
    • SpeakableTextPresentViewCheck If the view is focusable, this checks whether valid speakable text exists, and errors if the view is missing speakable text needed for a screen reader.
    • EditableContentDescViewCheck Throws an error if Editable TextView has a contentDescription.
    • ClickableSpanViewCheck Checks if ClickableSpan is inaccessible. Individual spans cannot be selected independently in a single TextView, and accessibility services are unable to call ClickableSpan#onClick.
    • RedundantContentDescViewCheck Accessibility services are aware of the view's type and can use that information as needed. For example, it throws a warning if the content description has a redundant word, such as “button.”
    • DuplicateClickableBoundsViewCheck Throws an error if Clickable view has the same bounds as another clickable view (likely a descendent). Sometimes there are containers marked clickable, and they don't process any click events.

提交回复
热议问题