横屏Android的输入法避免全屏处理
横屏Android的输入法避免全屏处理
Android输入法PinyinIME 或 Softkeyboard,在ORIENTATION_LANDSCAPE的机器上就会进入全屏模式,也就是文本框变大,除了文本框和什么都不显示了(其实可能也没有太多空间显示,不过如果是个大屏幕就难看的很了),要想解除全屏模式,需要参考如下的办法。
其实修改很简单,代码路径:platform/frameworks/base/core/java/android/inputmethodservice/InputMethodService.java
749 /**
750 * Re-evaluate whether the input method should be running in fullscreen
751 * mode, and update its UI if this has changed since the last time it
752 * was evaluated. This will call {@link #onEvaluateFullscreenMode()} to
753 * determine whether it should currently run in fullscreen mode. You
754 * can use {@link #isFullscreenMode()} to determine if the input method
755 * is currently running in fullscreen mode.
756 */
757 public void updateFullscreenMode() {
-- 758 boolean isFullscreen = mShowInputRequested && onEvaluateFullscreenMode();
++ 758 boolean isFullscreen = false;
759 boolean changed = mLastShowInputRequested != mShowInputRequested;
760 if (mIsFullscreen != isFullscreen || !mFullscreenApplied) {
761 changed = true;
762 mIsFullscreen = isFullscreen;
763 InputConnection ic = getCurrentInputConnection();
764 if (ic != null) ic.reportFullscreenMode(isFullscreen);
765 mFullscreenApplied = true;
834 /**
835 * Override this to control when the input method should run in
836 * fullscreen mode. The default implementation runs in fullsceen only
837 * when the screen is in landscape mode. If you change what
838 * this returns, you will need to call {@link #updateFullscreenMode()}
839 * yourself whenever the returned value may have changed to have it
840 * re-evaluated and applied.
841 */
842 public boolean onEvaluateFullscreenMode() {
843 Configuration config = getResources().getConfiguration();
844 if (config.orientation != Configuration.ORIENTATION_LANDSCAPE) {
845 return false;
846 }
847 if (mInputEditorInfo != null
848 && (mInputEditorInfo.imeOptions & EditorInfo.IME_FLAG_NO_FULLSCREEN) != 0) {
849 return false;
850 }
851 return true;
852 }
ORIENTATION_LANDSCAPE模式就是所谓的横屏模式,参见Layout。只要LANDSCAPE就全屏,那必须是横屏又不能全屏的直接设置为false即可。
|
评论暂时关闭