OnScreen keyboard opens automatically when Activity starts

后端 未结 5 1554
没有蜡笔的小新
没有蜡笔的小新 2020-12-25 10:10

When my Activity with a ScrollView layout and EditTexts starts, the EditTexts get focus and the Android OnScreen keyboard opens.

相关标签:
5条回答
  • 2020-12-25 10:36

    This will an inappropriate behaviour

    getWindow().setSoftInputMode(
    WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);       
    

    but it will do it smoothly(do it in manifest for that activity)

     android:windowSoftInputMode="stateHidden"
    
    0 讨论(0)
  • 2020-12-25 10:37

    Another way is by adding on LinearLayout:

    android:focusable="true"
    
    android:focusableInTouchMode="true"
    

    Let me indicate that

    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
    

    still does the same thing, but the cursor is still there.

    0 讨论(0)
  • 2020-12-25 10:39

    You can use below statement also,

    (EditTextName).setInputType(0)

    it will permanently hides default keyboard of perticular Edittext, even on EditText Touch or Click.

    0 讨论(0)
  • 2020-12-25 10:44

    Android opens the OnScreenKeyboard automatically if you have an EditText focussed when the Activity starts.

    You can prevent that by adding following into your Activity's onCreate method.

     getWindow().setSoftInputMode(
        WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
    
    0 讨论(0)
  • 2020-12-25 10:48

    If you want to do it editing the AndroidManifest:

            <activity
            android:name=".Dades"
            android:label="@string/app_name" 
            android:windowSoftInputMode="stateHidden">
    

    the line android:windowSoftInputMode="stateHidden" is the one that prevents the keyboard focus.

    0 讨论(0)
提交回复
热议问题