I have an activity
with a search box (EditText
) on the top, and a ListView below. Whenever the activity starts, the EditText always has focus and bring up the keyboard which partially cover the ListView
.
There's no other text view
that can have focus.
I want the EditText to have focus ONLY when the user touches it and start typing. I try to put clearFocus() in onCreateView
, onViewCreated
or onCreated
, but no luck.
Set in your parent layout next attributes:
And now, when
activity
starts this layout getting default focus.Also we can remove focus from children views in runtime (e.g. after finishing child editing):
or
Look in the AndroidManifest.xml element.
It always hide key board when entering the activity.
You could use set focus on container view. Add to container android:focusableInTouchMode="true", android:focusable="true" and tag requestFocus example: