I can see importantForA11y
is for minSdk=6+
But why would one have to use it, if they can just use setConentDescription=@null
?
What is the difference between importantForA11y=false
vs. setConentDescription=@null
vs. focusable=false
I can see importantForA11y
is for minSdk=6+
But why would one have to use it, if they can just use setConentDescription=@null
?
What is the difference between importantForA11y=false
vs. setConentDescription=@null
vs. focusable=false
Copyright © 2021 Jogjafile Inc.
ImportantForAccessibility=false
is used to hide any element from the accessibility tree, including buttons, content etc.contentDescription=null
is only useful for things like images (there may be other items I can't think of) that you want to hide as otherwise the Accessibility Tree will do it's best to find a suitable name for an item.A prime example would be an
ImageButton
- if you usecontentDescription=null
then it will announce 'button' and the destination / button text. If you useImportantForAccessibility=false
it would hide that item completely from the accessibility tree.The best analogy I can come up with (if you are familiar with Web Standards) is that
contentDescription
is like analt
attribute oraria-labelledby
attribute andImportantForAccessibility=false
is similar toaria-hidden="true"
.With regards to
focusable=false
, this should be used for things likeImageView
s, it should always be used in conjunction withimportantForAccessibility=false
(orimportantForAccessibility="no"
) to ensure an item that is purely decorative is completely removed from the accessibility tree.There are probably some edge cases I can't think of so above all, test it with
TalkBack
or a similar screen reader.