Hide soft keyboard on application load
I have an application with an EditText
element on the main view.
This means that when my applic开发者_运维问答ation is loaded the soft keyboard appears per default.
I would like to be able to hide the keyboard on load,
so it does not show until i tap on the EditText
view.
How do i manage this?
You can do something easier. Add this to the LinearLayout (or any other layout that is the root):
<LinearLayout
...
android:focusable="true"
android:focusableInTouchMode="true"
...
/>
InputMethodManager imm =
(InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(myEditText.getWindowToken(), 0);
This will hide in all situations (even when the EditView has focus):
EditText editView = (EditText) findViewById(R.id.editTextConvertValue);
editView.setInputType(InputType.TYPE_NULL);
You can hide keyboard when page open easily
Add these two properties on root layout
android:focusable="true"
android:focusableInTouchMode="true"
Sample code
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="true"
android:focusableInTouchMode="true">
精彩评论