hide keyboard android

public void hideKeyboard(Context context, View view) {
    InputMethodManager imm = (InputMethodManager) context.getSystemService(Activity.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}

// call from inside an Activity...
hideKeyboard(this, view);
hideKeyboard(this, getCurrentFocus());
hideKeyboard(this, getWindow().getDecorView());
hideKeyboard(this, findViewById(android.R.id.content));

3.38
8
Lionel Aguero 33605 points

                                    //With AndroidX:
fun View.hideKeyboard() = ViewCompat.getWindowInsetsController(this)
    ?.hide(WindowInsetsCompat.Type.ime())

3.38 (8 Votes)
0
4
6
Awgiedawgie 440215 points

                                    
class CloseHideSoftKeyboard : AppCompatActivity() {
  
 override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_message)

        val editTextXml = findViewById<EditText>(R.id.editText)
        val btnSendMessage = findViewById<Button>(R.id.btnSend)
        
        btnSendMessage.setOnClickListener{
          // ... you actions
          // Important! EditText must have be focused 
          // do action close keyboard first before go to another
          // activity or fragment
        	closeSoftKeyboard(this, editTextXml)
        }
    }



   /* hide soft keyboard after writing and sending message or any */
   private fun closeSoftKeyboard(context: Context, v: View) {
        val iMm = context.getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager
        iMm.hideSoftInputFromWindow(v.windowToken, 0)
        v.clearFocus()
    }
}
// link to resourse (Russian version)
// https://issue.life/questions/1109022/close-hide-the-android-soft-keyboard

4 (6 Votes)
0
4.14
7
Awgiedawgie 440215 points

                                    <activity android:name="com.your.package.ActivityName"
          android:windowSoftInputMode="stateHidden"  />

4.14 (7 Votes)
0
4
8
IllusiveBrian 18110 points

                                        private void closeSoftKeyboard() 
    { 
    	//If using a fragment use getActivity().getCurrentFocus()
        View v = this.getCurrentFocus(); 
  
  		// If Soft Keyboard is visible, it will be hide
        if (v != null) { 
          //If using a fragment use getActivity().getSystemService(...)
            InputMethodManager inputManager 
                = (InputMethodManager) 
                    getSystemService(Context.INPUT_METHOD_SERVICE); 
            inputManager.hideSoftInputFromWindow(v.getWindowToken(), 0); 
        } 
    } 

4 (8 Votes)
0
4
3
Krish 100200 points

                                    InputMethodManager inputManager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); 
inputManager.hideSoftInputFromWindow(this.getCurrentFocus().getWindowToken(),InputMethodManager.HIDE_NOT_ALWAYS); 

4 (3 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
hide keyboared android kotlin android hide soft keyboard hide keyboard android. kotlin HOW to hide keyboard throught key DONE in android kotlin how to hide the keyboard in android studio hide keyboared kotlin anroid popper hiding keyboard on android hide keyboard programmatically android on button click android hide edittext keyboard hide keyboard android manifest how to hide keyboard in android kotlin android hide keyboard at oncreate how to make keyboard hide after entering text in android hide the keyboard in navigation android hide the keyboard with navigation kotlin android hide the keyboard kotlin android keyboard enter liatener android to hide keyboard when edittext false hide keyboard in android android emulator hide keyboard how to hide keyboard in android keyboard hide in android android hid keyboard android make keyboard disappear hide keyboard in android How to hide keyboard in android studio hide keyboard android programmatically javascript hide keyboard android app hide keyboard in android emulator hide keyboard android edittext android kotlin keyboard hide detect keyboard hide on android edittext keyboard hide android android keyboard how can hide android keyboard how can hide android keyboard hide detect hide keyboard when first start activity android hide keyboard focus android hide keyboard activity android hide button when keyboard open activity android android keyboard hide field android hide keyboard login form when edit text click keyboard hide in android done button click hide on keyboard android how to hide keyboard after typing in edittext in android hide keyboard on activity start android programmatically hide keyboard on activity start android android studio hide screen keyboard android 11 hide keyboard android 11 remove hide keyboard button how to hide keyboard programmatically in android android hideing number keyboard shows another keyboard android hide keyboard shows another keyboard android hide keyboard shows other keyboard android hide keyboard on click android hide keyboard kotlin hide keyboard android java how to permanently hide the java android soft keyboard hide keyboard when click button android hide keyboard when click on layout android android hide keyboard without view hide Keyboard in fragment android java hide Keyboard programmatically android java hide keyboard android keyboard hide button android android kotlin hide keyboard how to hide soft keyboard in android programmatically android hide view behind keyboard hide keyboard kotlin hiding keyboard java android android command hide keyboard hide soft input android hide all keyboard in android androod kotlin hide keyboard Hide keyboard Android on button click android java hide keyboard hide keyboard on button click android how to hide the keyboard in android android keyboard hide hide keyboard programmatically android kotlin hide keyboard hide keyboard android kotlin fragment android kotlin force hide keyboard android keyboard does not hide hide all keyboards in android android studio kotlin how hide screan keyboard programicly hide keyboard in activity keyboard hide edittext android android hide keyboard is show programmatically android disable hide keyboard code to hide the keyboard android kotlin code to hide the keyboard android Close/Hide the Soft Keyboard in Android Android Kotlin hide input keyboard hide keyboard in android kotlin android studio hide keyboard android hide keyboard programmatically android studio hide keyboard on button click kotlin android studio hide keyboard on button click hide keyboard that work on all android devices latest way to show and hide keyboard in android using window manager latest way to show and hide keyboard in android android hide keyboard hide keyboard android programmatically android studio show hide keyboard hide the keyboard android android keyboard prevent resize android hide soft keyboard on edittext focus hide soft keyboard android hide keyboard android studio kotlin hidekeyboard in android how to hide keyboard in kotlin how to close soft keyboard in android hide keyboard android kotlin to all app android android keyboard kotlin get keyboard down after enter kotlin hide keyboard after typing android how to hide keyboard in android fragment kotlin android hide keyboard in fragment android close keyboard on enter koltin android studio close keyboard android close soft keyboard how to hide keyboard on activity start hide keyboard programmatically make android soft keyboard disappear automatically hide keyboard suggestion android kotlin how to hide soft keyboard in android How to programmatically hide Android soft keyboard kotlin close keyboard hide keyboard from activity android close the keyboard android android hide keyboard high api hide keyboard programmatically android kotlin how to hide the keyboard automatically typing hide keyboard in fragment android kotlin close soft keypad on click of screen in android using kotlin hide keyboard on button click android kotlin hide soft keyboard android kotlin close keyboard edittext android hide keyboard in kotlin hide keyboard android kotlin close keyboard on activity start android android edittext close keyboard android hide keyboard after enter android activity keyboard hide android edittext dismiss keyboard
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source