Home » Android » XML attribute usage "android:focusableInTouchMode"

XML attribute usage "android:focusableInTouchMode"

Posted by: admin June 16, 2020 Leave a comment


Please tell me why is the following XML attribute used ?
I looked up the documentation on developer.android.com but could not understand anything.

How to&Answers:

This blog post can help you to understand the meaning of touch mode.

The most relevant part :

The touch mode is a state of the view hierarchy that depends solely on the user interaction with the phone. By itself, the touch mode is something very easy to understand as it simply indicates whether the last user interaction was performed with the touch screen. For example, if you are using a G1 phone, selecting a widget with the trackball will take you out of touch mode; however, if you touch a button on the screen with your finger, you will enter touch mode. When the user is not in touch mode, we talk about the trackball mode, navigation mode or keyboard navigation, so do not be surprised if you encounter these terms. Finally, there is only one API directly related to touch mode, View.isInTouchMode().

So android:focusableInTouchMode="true" means that the view can get the focus when the phone is in touch mode.

Typically an EditText is generally focusable in touch mode and on the other hand a Button is generally not focusable in touch mode.


Happened to me when I didn’t have the correct number of items in getItemCount().

Double check that you have the right number of items!