254
votes

On Android devices that use soft keyboards, I want to prevent the fullscreen keyboard editing view (shown below) from appearing when in landscape mode (i.e. I want to see only the soft keyboard itself and my view behind it).

I assume this can be achieved using the setExtractViewShown(false) method on InputMethodService, but I am unable to access the default instance of this and do not want to implement a custom input method.

Android fullscreen editing view

Edited to add: the view to which input is going is not a TextView (it's a View with a custom InputConnection implementation), so android:imeOptions="flagNoExtractUi" won't work here.

11
Let try to see it. It's good for you. [Look to this one][1] [1]: stackoverflow.com/questions/8648401/…sonida
i have a similar problem :( you might have any idea? stackoverflow.com/questions/36914290/…railwanderer
how to apply this throughout the whole app.We are not going to add the attribute-value in every edittext in xml.Vikas Pandey
Many of the answers below recommend using flagNoExtractUi or IME_FLAG_NO_EXTRACT_UI. However,in the documentation for IME_FLAG_NO_EXTRACT_UI, which corresponds to flagNoExtractUi, it states that "Using this flag is discouraged and it may become deprecated in the future", so flagNoFullscreen is the recommended option.ThomasW

11 Answers

184
votes

I finally answered my own question:

The extract UI (i.e. the fullscreen editing mode) can be disabled at the point at which the input connection is hooked up:

@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {

    outAttrs.imeOptions = EditorInfo.IME_FLAG_NO_EXTRACT_UI;

    // etc.
}
119
votes

To do that, navigate to activity xml and paste android:imeOptions="flagNoExtractUi" in your code. But where should it be pasted? Have look at code of example activity xml and look at EditText:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"         
    >

    <EditText
        android:imeOptions="flagNoExtractUi"

        android:id="@+id/etTextInAct"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10" >   
        <requestFocus />
    </EditText>

</LinearLayout>
      

If you want more customisation options for the keyboard see http://developer.android.com/guide/topics/ui/controls/text.html

67
votes

add the property android:imeOptions="flagNoExtractUi" to each EditText in your XML file.

54
votes

The answer above helped me figure out the solution for dynamically added EditTexts:

editText.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
41
votes

Use android:imeOptions="flagNoFullscreen" to achieve that feature.

13
votes

Also, if you want to combine multiple imeOptions programaticaly, you can use the | syntax.

For example, in order to disable the fullscreen edit view in landscape and replace "Next" key by "OK" (ACTION_DONE) in keyboard, you can use:

editText.setImeOptions(EditorInfo.IME_ACTION_DONE | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
9
votes

If you're modifying the IME directly you can prevent it from ever displaying an ExtractedView by overriding onUpdateExtractingVisibility:

@Override
public void onUpdateExtractingVisibility(EditorInfo ei) {
    ei.imeOptions |= EditorInfo.IME_FLAG_NO_EXTRACT_UI;
    super.onUpdateExtractingVisibility(ei);
}
8
votes

My solution:

android:imeOptions="flagNoExtractUi|flagNoFullscreen"
6
votes

I know it's a little bit late but for anyone who is still interested, here is my solution : In my case I had a landscape Activity containing an EditText at top of it and I needed to implement autocomplete feature in this search Activity, which the overlapping keyboard caused an issue that the user could not see result of RecyclerView. So I ended up having this EditText in my layout:

<EditText
  android:layout_width="match_parent"
  android:layout_height="?actionBarSize"
  android:id="@+id/main_search_et"
  android:imeOptions="actionSearch|flagNoExtractUi"
  android:inputType="text"  />

Cheers!

2
votes

You can use :

android:imeOptions="flagNoFullscreen" 

in your edittext

0
votes

You can call to hide soft keyboard and clear focus from searchview.

public void hideKeyboard(View view) {
    InputMethodManager imm = (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}

super.clearFocus();