Created
April 6, 2020 20:41
-
-
Save miguelhincapie/f0de6dd92b0b21a2919c0496426e61f8 to your computer and use it in GitHub Desktop.
Extension functions to enable/disable accessibility focus.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Extension function to set touch values for accessibility | |
*/ | |
fun List<View>.enableAccessibilityFocus() { | |
this.forEach { | |
it.setAccessibilityFocus() | |
} | |
} | |
/** | |
* Extension function to remove touch values for accessibility | |
*/ | |
fun List<View>.disableAccessibilityFocus() { | |
this.forEach { | |
it.setAccessibilityFocus(false) | |
} | |
} | |
/** | |
* Extension function to set touch/remove values for accessibility depends on params value | |
*/ | |
fun View.setAccessibilityFocus(value: Boolean = true) { | |
this.isFocusableInTouchMode = value | |
this.isFocusable = value | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment