I often encounter very small problems in development. Let’s record them here.
Usually added inandroid:windowSoftInputMode="adjustResize"
Or adjustPan, the software disk will automatically pop up when the EditText control is entered.
1. Add in the parent layout containing EditTextandroid:focusable="true" and android:focusableInTouchMode="true"
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:andro android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:focusable="true" android:focusableInTouchMode="true" > <EditText android: android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="text" android:maxLines="1" /> </LinearLayout>
This prevents the automatic ejection of soft keyboards
2. Add stateHidden to it, so it won't pop up automatically
<activity android:name=".TestAActivity" android:windowSoftInputMode="adjustResize|stateHidden"> </activity>
3. Enter the page to hide the soft keyboard
If neither of the first two methods work, you can use this method:
/** * Hide input soft keyboard * @param context * @param view */ public static void hideInputManager(Context context,View view){ InputMethodManager imm = (InputMethodManager) (Context.INPUT_METHOD_SERVICE); if (view !=null && imm != null){ ((), 0); // Force hiding } }
Summarize
The above is the method of Android prohibiting EditText from automatically popping up soft keyboards. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to everyone in time. Thank you very much for your support for my website!