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.
You can force Android to hide the virtual keyboard using the InputMethodManager, calling hideSoftInputFromWindow, passing in the token of the window containing your edit field. This will force the keyboard to be hidden in all situations.
I think the following may work
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
I've used it for this sort of thing before.
Try this -
this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
Alternatively,
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".Main"
android:label="@string/app_name"
android:windowSoftInputMode="stateHidden"
>
android:windowSoftInputMode
for a value like adjustResize
or adjustPan
, you can combine two values like:<activity
...
android:windowSoftInputMode="stateHidden|adjustPan"
...
>
This will hide the keyboard whenever appropriate but pan the activity view in case the keyboard has to be shown.
Hide it for all activities using the theme
<style name="MyTheme" parent="Theme">
<item name="android:windowSoftInputMode">stateHidden</item>
</style>
set the theme
<application android:theme="@style/MyTheme">
Add these two properties to your parent layout (ex: Linear Layout, Relative Layout)
android:focusable="false"
android:focusableInTouchMode="false"
It will do the trick :)
If you are using API level 21, you can use editText.setShowSoftInputOnFocus(false);
Try to declare it in manifest file
<activity
android:name=".HomeActivity"
android:label="@string/app_name"
android:windowSoftInputMode="stateAlwaysHidden" >
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