There is this widget for the ActionBar which called \'SearchView\'. When it\'s not in use, it looks like this:
For androidx.appcompat.widget.SearchView,
searchView.setIconifiedByDefault(true) // didn't work
searchMenuItem.expandActionView() // didn't work
MenuItemCompat.expandActionView(searchMenuItem) // didn't work
searchView.onActionViewExpanded() // didn't work
The following worked for me,
searchView.findViewById(R.id.search_button).performClick()