Success Criterion 1.4.13 - Level AA
Content on Hover or Focus
Ensure it possible to hide content which appears automatically when touching an element. It often happens that an element is touched accidentally. If new content appears, it may affect the completion of a task. Automatic content mainly causes problems for users of assistive technologies.
Impact
Users of assistive technologies can get stuck in an app if it is not possible to hide automatically appearing content.
A menu may open after a click. Users should be able to stop or undo this action.
Check
“Can content be hidden if it gets in the way?“
You can use the screen reader or keyboard to check this.
Solution
Add a close button to content that is automatically displayed to allow users of assistive technologies to hide it.
Add close button
On Android, you can show a dialog by using AlertDialog
, BottomSheetDialog
or DialogFragment
. You should always add a close button by using the setNegativeButton
method. The focus of assistive technologies is automatically trapped inside the dialog while it's visible.
val builder = AlertDialog.Builder(this)
builder.setTitle("Confirm Appt membership?")
builder.setMessage("Your bank account will be billed.")
builder.setPositiveButton("Proceed") { dialog, which ->
// Proceed
}
builder.setNegativeButton("Cancel") { dialog, which ->
// Cancel
}
builder.show()