What's the Android “Extracted Text UI”?

2019-05-05 01:16发布

问题:

I recently had a bug where my small EditText was ballooning up to fill whatever space wasn't consumed by the soft keyboard. But only in Landscape mode.

I posted this and got a quick response from a helpful StackOverflow member that I needed to add android:imeOptions="flagNoExtractUi", so I did and it worked!

But I still don't understand it. The documentation says that it's "Used to specify that the IME does not need to show its extracted text UI" OK, what's that? The "search developer docs" feature of http://developer.android.com shows the phrase "Extracted text UI" used 34 times in their documentation but I didn't notice a definition.

Could someone please explain what it is, and why it only affects Landscape mode? Thanks in advance.

回答1:

In landscape mode, by default, the Input Method Editor (IME) gets control of the full screen when editing text. The idea is that there isn't enough room "vertically" on the landscape screen to show anything other than the EditText and the soft keyboard when editing something longer (e.g. an e-mail message).

The UI in question is here: http://developer.android.com/reference/android/inputmethodservice/ExtractEditText.html



回答2:

When you use that flag in a TextView in your app , it suppresses the creation of an ExtractedTextView at the top of the IME when it is in "full screen" mode. When in "full screen" mode, the keyboard (the IME) is allowed to fill the screen and cover the app's TextView which the user is trying to edit. If it asks for the full screen, it'll be given to it. This ExtractedTextView box shows the same hints appearing in the targeted TextView, and let's the user see their editing progress. That flag tells the IME not to generate the ExtractedTextView which might leave some room at the top of the keyboard to see your original TextView in the app.

The default implementation of an IME (keyboard) goes to full screen mode when in "landscape mode". It's regular size (about 1/3 of the screen height?) in "portrait mode". The ExtractedTextView is generated, by default, for "full screen" mode, unless you suppress it. I suspect that when you see your EditText "balloning", your actually looking at the ExtractedTextView of a "full screen" mode keyboard.