Here is my solution. This is a bit of a workaround, but still works for me.
private boolean activityStartup = true;
searchView.setIconifiedByDefault(false);
searchView.setOnQueryTextFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
if (activityStartup) {
searchView.clearFocus();
activityStartup = false;
}
}
}
});
Thus, the query hint is always displayed, and when (and only when) the first activity is launched, the SearchView focus is automatically cleared, hiding the keyboard. The keyboard will be displayed with manual or manual orientation of the SearchView.
source
share