Success Criterion 1.4.13 - Level AA
Content on Hover or Focus
Ensure that content shown after hover or focus can be hidden. Content must remain visible until the reason for the hover or focus disappears. In addition, users need to be able to dismiss the content.
Impact
Users can get stuck in an app if it is not possible to hide automatically appearing content.
A menu may open after ho. Users should be able to stop or undo this action.
Check
“Can content be hidden if it gets in the way?“
You can use a pointer of keyboard to check this.
Solution
Add a close button to content that is automatically displayed to allow users 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()