How can I prevent both the keyboard and the menu from being shown together? <p>Here's a screenshot of my application. When the search box is clicked, the soft-keyboard automatically pops up, which is fine, but, if I also press the "Menu" button, the menu appears on top of the soft-keyboard. </p> <p>How can I show the menu but collapse the <code>SearchView</code> if it is in focus and also hide the soft-keyboard. I probably need to check and do something in the <code>onPrepareOptionsMenu</code> method of my <code>Activity</code>, right?</p> <p>It doesn't cause any real harm to me but it seems like an ugly implementation to the user when this happens.</p> <p><img src="https://i.stack.imgur.com/FQckf.jpg" alt="enter image description here"></p>