What is the difference between clickable
and focusable
in android?
Clickable means that it can be clicked by a pointer device or be tapped by a touch device. Focusable means that it can gain the focus from an input device like a keyboard.
Focusable in touch mode is a property that you can set yourself either from code or XML. However, it should be used sparingly and only in very specific situations as it breaks consistency with Android normal behavior.
Your view can have different background when state is focused. Focusable in touch mode allows view to gain focus when user is touching the view, good example of this kind of component is EditText . With Button or any clickable component pressed state is usually what you are interested in.
Clickable
means that it can be clicked by a pointer device or be tapped by a touch device. Focusable
means that it can gain the focus from an input device like a keyboard. Input devices like keyboards cannot decide which view to send its input events to based on the inputs itself, so they send them to the view that has focus.
Focusable
means ACTION_UP event will occur. It will gain it and it won't release it.
Clickable
means ACTION_DOWN first and ACTION_UP at the end. It will gain and release it at the end.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With