I got a relative simple question. I have an activity with a lot of EditText's in them. When I open the activity it automatically focusses to the first EditText and displays the virtual keyboard.
How can I prevent this?
You can force Android to hide the virtual keyboard using the InputMethodManager, calling hideSoftInputFromWindow , passing in the token of the window containing your focused view. This will force the keyboard to be hidden in all situations. In some cases you will want to pass in InputMethodManager.
Use this attributes in your layout tag in XML file:
android:focusable="true" android:focusableInTouchMode="true"
As reported by other members in comments it doesn't works on ScrollView
therefore you need to add these attributes to the main child of ScrollView
.
You can add this to your Android Manifest activity:
android:windowSoftInputMode="stateHidden|adjustResize"
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