title: How to hide keyboard just by one tap outside of an edittext?
body: <p>I want to hide the keyboard by tapping outside of edittext. This is my xml code:</p>
  
  <pre><code>&lt;RelativeLayout
  android:clickable="true"
  android:focusable="true"
  android:focusableInTouchMode="true"
  android:onClick="rl_main_onClick"&gt;
  &lt;RelativeLayout
    //Here there are some widgets including some edittext.
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>This is my java code (MainActivity):</p>
  
  <pre><code>public void rl_main_onClick(View view) {
      InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
      imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
  }
  </code></pre>
  
  <p>But I have to tap twice to hide keyboard. The first tap just changes "next" (for last edittext it's "done") to "enter" icon, then the second tap hides the keyboard.
  This is what that happen by the first tap:</p>
  
  <p><a href="https://i.stack.imgur.com/rCnwz.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rCnwz.jpg" alt="What the first tap does."></a></p>
  
  <p>Now I have two questions:</p>
  
  <ol>
  <li><p>How can I fix it and hide keyboard by just one tap?</p></li>
  <li><p>Is it possible to do it for all of my edittext (one code for all)?</p></li>
  </ol>