Disabling the fullscreen editing view for soft keyboard input in landscape?
Asked Answered
P

12

269

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.

Palma answered 2/12, 2010 at 15:42 Comment(4)
Let try to see it. It's good for you. [Look to this one][1] [1]: #8648901Mccubbin
i have a similar problem :( you might have any idea? #36914790Dichroscope
how to apply this throughout the whole app.We are not going to add the attribute-value in every edittext in xml.Wondering
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.Koval
P
187

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.
}
Palma answered 18/1, 2011 at 16:47 Comment(10)
just simply put in your xml file android:imeOptions="flagNoExtractUi"Fradin
jnic, where did you do that override at in the soft keyboard code? SoftKeyboard.java? I tried the same override and error'd out.Fearful
hey jnic. I am doing it in the same way but its not working for me.. i am still getting fullscreen keyboard editing view.Emelineemelita
You'll probably want to add the flag to the options instead of overriding what ever options were being passed in like this: outAttrs.imeOptions |= EditorInfo.IME_FLAG_NO_EXTRACT_UI;Gyre
@Emelineemelita I think he means to put this method under every EditText View you want the full screen styled to be disabled.Balzer
@Fradin how to apply this attribute on the searchbox item in action bar ?Roger
It's enough to just add android:imeOptions="flagNoExtractUi" inside a particular EditText element.Mahau
better to use flagNoFullscreen as it does not lock editing options and drag-and-drop on N between activitiesThing
There is not exact implementation. where should it be used and what should return in method.Circumspect
The only thing worked when using custom View to handle keyboard. Thanks!Commando
S
131

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

Stickybeak answered 1/11, 2012 at 15:3 Comment(1)
FYI EditorInfo.IME_FLAG_NO_EXTRACT_UI suggests using IME_FLAG_NO_FULLSCREEN instead.Kurdish
Z
68

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

Zulema answered 3/11, 2013 at 21:46 Comment(6)
This answer is too short and doesn't meet SO quality standards. Please improve it adding some additional explanations, so that it will be useful for the community and not only for the OP.Actinomycosis
@LorenzoDonati it's exactly what you have to do... it's a very simple answer because the solution is very simple and it's just a different way of doing it than the answers above. Also, answers can't be "too short" unless they don't answer the question, IMO.Zulema
Sorry, but this is not what the SO community thinks about it. The answers should not be limited to solve the OP's problem, they should be great answers in general. See this and this, for example.Actinomycosis
@LorenzoDonati it is a very specific question with only one end result (but multiple ways to solve it). My answer is an addition to the other answers on this page. ALL of the answers on this page are only limited to the "OP's problem" because that's the only kind of answer that can be written. Like I said, it's specific and simple.Zulema
finally, i found the answer. thank you so much @mike yaworskiAngelita
@LorenzoDonati The question states that android:imeOptions="flagNoExtractUi" won't work here. That would have been a much better platform than attempting to suggest readers are subjected to unnecessary rambling.Schleswigholstein
B
56

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

editText.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
Bergen answered 18/10, 2012 at 11:40 Comment(0)
S
44

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

Salmi answered 25/4, 2014 at 17:28 Comment(2)
nice and better approach to write in xml. Works for me. ThanksDene
Note that 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.Koval
D
14

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);
Dagall answered 8/3, 2016 at 9:15 Comment(0)
V
12

My solution:

android:imeOptions="flagNoExtractUi|flagNoFullscreen"
Vasili answered 17/9, 2018 at 14:42 Comment(1)
This is a more up-to-date answer.Incoming
G
9

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);
}
Gyre answered 4/12, 2012 at 0:30 Comment(0)
W
6

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!

Wheeled answered 16/12, 2017 at 15:16 Comment(0)
L
2

You can use :

android:imeOptions="flagNoFullscreen" 

in your edittext

Laomedon answered 27/9, 2017 at 2:54 Comment(2)
Is this an answer?Diplomat
I try it and it work for me! (My device is android 4.1.2)Laomedon
R
0

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();
Rupertruperta answered 10/6, 2018 at 12:3 Comment(0)
P
0

To prevent the fullscreen keyboard in Android, use the android:imeOptions="flagNoFullscreen" property for each EditText in your XML file. It's recommended over flagNoExtractUi, which might get deprecated.

More details can be found in the Android documentation

How to use: -

<EditText
    android:id="@+id/editText"
    android:imeOptions="flagNoFullscreen"
    ... />
Plashy answered 5/1 at 6:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.