I have a layout that contains many views. Is there an easy way to disable all its views click events?
If you dont want to set all child views to disable state (because they may look different to enable state) you can use this approach:
private fun toogleTouchable(canTouch: Boolean) {
container.descendantFocusability =
if (value) {
container.requestFocus()
ViewGroup.FOCUS_BLOCK_DESCENDANTS
} else {
ViewGroup.FOCUS_AFTER_DESCENDANTS
}
}