When building layouts in android, if you use an ImageView
or an ImageButton
without adding a content description, then you would get a warning telling you to add a content description to the views with AppCompatImageView
and AppCompatImageButton
that warning is no longer available. I thought this is because the implementation for AppCompatImageView
has a default content description based on the content of the view but talk back still reads it as an "un labelled button", why was the warning removed?
The content description attribute links a text description to a control, ImageView, or other focusable object that otherwise has no text content. These objects wouldn't be accessible without some some sort of label or description.
When using an ImageView , ImageButton , CheckBox , or other View that conveys information graphically, use an android:contentDescription attribute to provide a content label for that View . A content label sometimes depends on information only available at runtime, or the meaning of a View might change over time.
Non-textual widgets like ImageViews and ImageButtons should use the contentDescription attribute to specify a textual description of the widget such that screen readers and other accessibility tools can adequately describe the user interface.
This lint rule is designed to work on specific widget types. Currently, this rule is checking only ImageView
and ImageButton
widgets. The lack of warning for AppCompat
widgets is because they have never added them to the element list.
The source code of the current implementation shows that it is applied only to ImageView
and ImageButton
.
public Collection<String> getApplicableElements() {
return Arrays.asList(
IMAGE_BUTTON,
IMAGE_VIEW
);
}
I have filled a bug on the Android issue tracker to request them to add AppCompatImageView
and AppCompatImageButton
to this lint rule. You may star the issue to convey your support.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With