android prevent EditText from requesting focus automatically

I have a quite simple Layout with an EditText and a button. The problem is the keyboard appears immediately after the activity is started and the EditText gets the focus. I removed the </requestFocus> from XML and I also don’t do that in code. How can I prevent that behavior of EditText so the keyboard only appears after the used taps the editText?

  • Debugging a WebView (Ionic) app on Android via logcat
  • How to scan QRCode in android
  • Is it possible to prevent the Google Play app from creating a shortcut of my App on install?
  • Notifications in specific time every day android
  • How to implement Endless scrolling using StaggeredLayoutManager
  • The view is not attached to a window
  • Related posts:

    Android Studio: create Java project with no Android dependencies
    How to correctly show a popup menu below a TextView, similar to Spinner?
    How to migrate existing SQLite application to Room Persistance Library?
    Correct text color/appearance in AlertDialog
    A queue of background tasks in rxjava
    How to solve the BluetoothGatt : android.os.DeadObjectException error happened in Android?
  • Android: Drag and Drop issue
  • ADB throws SecurityException while starting service after system update to Nexus 7: “Caller uid=2000 is not privileged to communicate with user=-2”
  • Software keyboard resizes background image on Android
  • Issue scrolling WebView in NestedScrollView Android 2.3 or less
  • Toggle airplane mode in Android
  • Retrofit 2 with only form-data
  • 4 Solutions collect form web for “android prevent EditText from requesting focus automatically”

    in your manifiest.xml write the below code in your activity

    android:windowSoftInputMode="adjustNothing" 
    

    In your manifest.xml file, under the activity tag, place this:

    android:windowSoftInputMode="stateHidden"
    

    try this

    In your AndroidManifest.xml file write these lines

    <activity
            android:configChanges="keyboardHidden|orientation"
            android:name=".YourActivityName"
            android:windowSoftInputMode="stateHidden" />
    

    i just added details..

    From my POV a more elegant solution is:

    1. In XML add these lines to the main layout:

      <LinearLayout
          android:id="@+id/mainLayout"
          android:focusable="true"
          android:focusableInTouchMode="true"
          ...
          .../>
      
    2. And In Java in onCreate():

        LinearLayout mainLayout = (LinearLayout) findViewById(R.id.mainLayout);
        mainLayout.requestFocus();
      
    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.