java - Is there a way to avoid having fullscreen SearchView/Keyboard on landscape? -


i'm trying avoid having fullscreen keyboard editing on landscape in order access suggestions.

i read lot of threads explaining have add editorinfo flags flagnofullscreen and/or flagnoextractui.

i added them programmatically not helpful.

is there way figure out?

it took me while figure 1 out, it's quite simple.

initially created custom class extended searchview class, , used oncreateinputconnection() override, couldn't working way.

i got working in more simple way, 2 added lines of code.

you need call search.getimeoptions() current configuration, , "or" result editorinfo.ime_flag_no_extract_ui call setimeoptions():

search.setimeoptions(options|editorinfo.ime_flag_no_extract_ui); 

if don't "or" existing options, don't "search" completion button in lower right, "done" button instead.

here full oncreateoptionsmenu() override used test (i used searchview in xml, solution should work if you're not inflating searchview xml):

@override public boolean oncreateoptionsmenu(menu menu) {      getmenuinflater().inflate(r.menu.menu_main, menu);      searchmanager manager = (searchmanager) getsystemservice(context.search_service);      searchview search = (searchview) menu.finditem(r.id.action_search).getactionview();      searchableinfo si = manager.getsearchableinfo(getcomponentname());      //here magic happens:     int options = search.getimeoptions();     search.setimeoptions(options|editorinfo.ime_flag_no_extract_ui);     //!!!!!!!!!!!      search.setsearchableinfo(si);      search.setonquerytextlistener(new searchview.onquerytextlistener() {          @override         public boolean onquerytextsubmit(string query) {             return false;         }          @override         public boolean onquerytextchange(string query) {             return true;         }      });     return true; } 

here xml used searchview in menu_main.xml:

<item android:id="@+id/action_search"         android:title="search"         android:icon="@android:drawable/ic_menu_search"         app:showasaction="ifroom"         app:actionviewclass="android.support.v7.widget.searchview"         /> 

result without call setimeoptions():

before

result call setimeoptions():

enter image description here


Comments