Disabling the fullscreen editing view for soft keyboard input in landscape?
On Android devices that use soft keyboards, I want to prevent the fullscreen keyboard editing view (shown below) from appearing when in landscape mode (ie 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.
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.
I finally answered my own question:
The extract UI (ie 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.
}
To do that simply navigate to activity xml and paste android:imeOptions="flagNoExtractUi"
in your code. Hmm pretty simple - but where the hac it should 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
将属性android:imeOptions="flagNoExtractUi"
到XML
文件中的每个EditText
。
上一篇: 当edittext被关注时,键盘
下一篇: 禁用横向软键盘输入的全屏编辑视图?