This question already has an answer here:
I would like to be able to remove the focus from the EditText. For example if the Keyboard appears, and the user hides it with the back button, I would like the focus and the cursor to disappear. How can it be done?
try to use this one on your view it worked for me:
You can avoid any focus on your elements by setting the attribute android:descendantFocusability of the parent element.
Here is an example:
Here, the attribute android:descendantFocusability set to "blocksDescendants" is blocking the focus on the child elements.
You can find more info here.
You can make cursor and focus disappear by
But detect when the key board hide is a hard work.
The
EditText
will be able to get the focus when the user touch it. When the main layout (activity, dialog, etc.) becomes visible theEditText
doesn't automatically get the focus even though it is the first view in the layout.You can also include android:windowSoftInputMode="stateAlwaysHidden" in your manifest action section.
This is equivalent to :
but in XML way.
FYI, you can also hide the keyboard with codes: