网站关键字描述中国前十强集团

当前位置: 首页 > news >正文

网站关键字描述,中国前十强集团,网站开发免费,中国建工网校官网IME关于输入法横屏全屏显示问题-Android14 1、输入法全屏模式updateFullscreenMode1.1 全屏模式判断1.2 全屏模式布局设置 2、应用侧关闭输入法全屏模式2.1 调用输入法的应用设置flag2.2 继承InputMethodService.java的输入法应用覆盖onEvaluateFullscreenMode方法 InputMethod… IME关于输入法横屏全屏显示问题-Android14 1、输入法全屏模式updateFullscreenMode1.1 全屏模式判断1.2 全屏模式布局设置 2、应用侧关闭输入法全屏模式2.1 调用输入法的应用设置flag2.2 继承InputMethodService.java的输入法应用覆盖onEvaluateFullscreenMode方法 InputMethodManagerService启动-Android12 1、输入法全屏模式updateFullscreenMode frameworks/base/core/java/android/inputmethodservice/InputMethodService.java 1.1 全屏模式判断 boolean isFullscreen mShowInputRequested onEvaluateFullscreenMode();: 判断是否全屏显示输入法其中mShowInputRequested请求一般就是 true 。onEvaluateFullscreenMode(): 默认横屏全屏模式显示若在横屏下有EditorInfo.IME_FLAG_NO_FULLSCREEN或者EditorInfo.IME_INTERNAL_FLAG_APP_WINDOW_PORTRAIT不使用fullscreen-mode模式 /*** Override this to control when the input method should run in* fullscreen mode. The default implementation runs in fullsceen only* when the screen is in landscape mode. If you change what* this returns, you will need to call {link #updateFullscreenMode()}* yourself whenever the returned value may have changed to have it* re-evaluated and applied./ public boolean onEvaluateFullscreenMode() {Configuration config getResources().getConfiguration();if (config.orientation ! Configuration.ORIENTATION_LANDSCAPE) {return false;}if (mInputEditorInfo ! null ((mInputEditorInfo.imeOptions EditorInfo.IME_FLAG_NO_FULLSCREEN) ! 0// If app window has portrait orientation, regardless of what display orientation// is, IME shouldnt use fullscreen-mode.|| (mInputEditorInfo.internalImeOptions EditorInfo.IME_INTERNAL_FLAG_APP_WINDOW_PORTRAIT) ! 0)) {return false;}return true; }1.2 全屏模式布局设置 设置mFullscreenArea的LayoutParams属性全屏模式下lp.height 0;、lp.weight 1;添加ExtractView即布局frameworks/base/core/res/res/layout/input_method_extract_view.xml /** Re-evaluate whether the input method should be running in fullscreen* mode, and update its UI if this has changed since the last time it* was evaluated. This will call {link #onEvaluateFullscreenMode()} to* determine whether it should currently run in fullscreen mode. You* can use {link #isFullscreenMode()} to determine if the input method* is currently running in fullscreen mode./ public void updateFullscreenMode() {Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, IMS.updateFullscreenMode);boolean isFullscreen mShowInputRequested onEvaluateFullscreenMode();boolean changed mLastShowInputRequested ! mShowInputRequested;if (mIsFullscreen ! isFullscreen || !mFullscreenApplied) {changed true;mIsFullscreen isFullscreen;reportFullscreenMode();mFullscreenApplied true;initialize();LinearLayout.LayoutParams lp (LinearLayout.LayoutParams)mFullscreenArea.getLayoutParams();if (isFullscreen) {mFullscreenArea.setBackgroundDrawable(mThemeAttrs.getDrawable(com.android.internal.R.styleable.InputMethodService_imeFullscreenBackground));lp.height 0;lp.weight 1;} else {mFullscreenArea.setBackgroundDrawable(null);lp.height LinearLayout.LayoutParams.WRAP_CONTENT;lp.weight 0;}((ViewGroup)mFullscreenArea.getParent()).updateViewLayout(mFullscreenArea, lp);if (isFullscreen) {if (mExtractView null) {View v onCreateExtractTextView();if (v ! null) {setExtractView(v);}}startExtractingText(false);}updateExtractFrameVisibility();}if (changed) {onConfigureWindow(mWindow.getWindow(), isFullscreen, !mShowInputRequested);mLastShowInputRequested mShowInputRequested;}Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER); }2、应用侧关闭输入法全屏模式 2.1 调用输入法的应用设置flag 设置EditorInfo.IME_FLAG_NO_FULLSCREEN属性而EditorInfo.IME_INTERNAL_FLAG_APP_WINDOW_PORTRAIT属性是framework内部使用。 即xml布局中 android:imeOptionsflagNoFullscreen 或者代码设置mEdtView.setImeOptions(EditorInfo.IME_FLAG_NO_FULLSCREEN); imeOptions 属性并不只有IME_FLAG_NO_FULLSCREEN功能 IME_ACTION_UNSPECIFIED actionUnspecified IME_ACTION_NONE actionNone IME_ACTION_GO actionGo IME_ACTION_SEARCH actionSearch IME_ACTION_SEND actionSend IME_ACTION_NEXT actionNext IME_ACTION_DONE actionDone IME_ACTION_PREVIOUS actionPrevious IME_FLAG_NO_PERSONALIZED_LEARNING flagNoPersonalizedLearning IME_FLAG_NO_FULLSCREEN flagNoFullscreen IME_FLAG_NAVIGATE_PREVIOUS flagNavigatePrevious IME_FLAG_NAVIGATE_NEXT flagNavigateNext IME_FLAG_NO_EXTRACT_UI flagNoExtractUi IME_FLAG_NO_ACCESSORY_ACTION flagNoAccessoryAction IME_FLAG_NO_ENTER_ACTION flagNoEnterAction IME_FLAG_FORCE_ASCII flagForceAscii 设置 imeOptions 属性并不一定生效假如输入法应用覆盖了 onEvaluateFullscreenMode 方法 frameworks/base/core/java/android/view/inputmethod/EditorInfo.java /** Flag of {link #imeOptions}: used to request that the IME never go* into fullscreen mode.* By default, IMEs may go into full screen mode when they think* its appropriate, for example on small screens in landscape* orientation where displaying a software keyboard may occlude* such a large portion of the screen that the remaining part is* too small to meaningfully display the application UI.* If this flag is set, compliant IMEs will never go into full screen mode,* and always leave some space to display the application UI.* Applications need to be aware that the flag is not a guarantee, and* some IMEs may ignore it./ public static final int IME_FLAG_NO_FULLSCREEN 0x2000000;/** Masks for {link imeOptions}** pre* |——-|——-|——-|——-|* 1111 IME_MASK_ACTION* |——-|——-|——-|——-|* IME_ACTION_UNSPECIFIED* 1 IME_ACTION_NONE* 1 IME_ACTION_GO* 11 IME_ACTION_SEARCH* 1 IME_ACTION_SEND* 1 1 IME_ACTION_NEXT* 11 IME_ACTION_DONE* 111 IME_ACTION_PREVIOUS* 1 IME_FLAG_NO_PERSONALIZED_LEARNING* 1 IME_FLAG_NO_FULLSCREEN* 1 IME_FLAG_NAVIGATE_PREVIOUS* 1 IME_FLAG_NAVIGATE_NEXT* 1 IME_FLAG_NO_EXTRACT_UI* 1 IME_FLAG_NO_ACCESSORY_ACTION* 1 IME_FLAG_NO_ENTER_ACTION* 1 IME_FLAG_FORCE_ASCII* |——-|——-|——-|——-|/pre//** Extended type information for the editor, to help the IME better* integrate with it./ public int imeOptions IME_NULL;/** A string supplying additional information options that are* private to a particular IME implementation. The string must be* scoped to a package owned by the implementation, to ensure there are* no conflicts between implementations, but other than that you can put* whatever you want in it to communicate with the IME. For example,* you could have a string that supplies an argument like* codecom.example.myapp.SpecialMode3/code. This field is can be* filled in from the {link android.R.attr#privateImeOptions}* attribute of a TextView./ public String privateImeOptions null;/** Masks for {link internalImeOptions}** pre* 1 IME_INTERNAL_FLAG_APP_WINDOW_PORTRAIT* |——-|——-|——-|——-|/pre//** Same as {link android.R.attr#imeOptions} but for frameworks internal-use only.* hide/ public int internalImeOptions IME_NULL;frameworks/base/core/java/android/widget/TextView.java case com.android.internal.R.styleable.TextView_imeOptions:createEditorIfNeeded();mEditor.createInputContentTypeIfNeeded();mEditor.mInputContentType.imeOptions a.getInt(attr,mEditor.mInputContentType.imeOptions);break;/** Change the editor type integer associated with the text view, which* is reported to an Input Method Editor (IME) with {link EditorInfo#imeOptions}* when it has focus.* see #getImeOptions* see android.view.inputmethod.EditorInfo* attr ref android.R.styleable#TextView_imeOptions/ public void setImeOptions(int imeOptions) {createEditorIfNeeded();mEditor.createInputContentTypeIfNeeded();mEditor.mInputContentType.imeOptions imeOptions; }frameworks/base/core/res/res/values/attrs.xml !– Additional features you can enable in an IME associated with an editorto improve the integration with your application. The constantshere correspond to those defined by{link android.view.inputmethod.EditorInfo#imeOptions}. –attr nameimeOptions!– There are no special semantics associated with this editor. –flag namenormal value0x00000000 /!– There is no specific action associated with this editor, let theeditor come up with its own if it can.Corresponds to{link android.view.inputmethod.EditorInfo#IME_NULL}. –flag nameactionUnspecified value0x00000000 /!– This editor has no action associated with it.Corresponds to{link android.view.inputmethod.EditorInfo#IME_ACTION_NONE}. –flag nameactionNone value0x00000001 /!– The action key performs a gooperation to take the user to the target of the text they typed.Typically used, for example, when entering a URL.Corresponds to{link android.view.inputmethod.EditorInfo#IME_ACTION_GO}. –flag nameactionGo value0x00000002 /!– The action key performs a searchoperation, taking the user to the results of searching for the textthe have typed (in whatever context is appropriate).Corresponds to{link android.view.inputmethod.EditorInfo#IME_ACTION_SEARCH}. –flag nameactionSearch value0x00000003 /!– The action key performs a sendoperation, delivering the text to its target. This is typically usedwhen composing a message.Corresponds to{link android.view.inputmethod.EditorInfo#IME_ACTION_SEND}. –flag nameactionSend value0x00000004 /!– The action key performs a nextoperation, taking the user to the next field that will accept text.Corresponds to{link android.view.inputmethod.EditorInfo#IME_ACTION_NEXT}. –flag nameactionNext value0x00000005 /!– The action key performs a doneoperation, closing the soft input method.Corresponds to{link android.view.inputmethod.EditorInfo#IME_ACTION_DONE}. –flag nameactionDone value0x00000006 /!– The action key performs a previousoperation, taking the user to the previous field that will accept text.Corresponds to{link android.view.inputmethod.EditorInfo#IME_ACTION_PREVIOUS}. –flag nameactionPrevious value0x00000007 /!– Used to request that the IME should not update any personalized data such as typinghistory and personalized language model based on what the user typed on this textediting object. Typical use cases are:ulliWhen the application is in a special mode, where users activities are expectedto be not recorded in the applications history. Some web browsers and chatapplications may have this kind of modes./liliWhen storing typing history does not make much sense. Specifying this flag intyping games may help to avoid typing history from being filled up with words thatthe user is less likely to type in their daily life. Another example is that whenthe application already knows that the expected input is not a valid word (e.g. apromotion code that is not a valid word in any natural language)./li/ulpApplications need to be aware that the flag is not a guarantee, and some IMEs maynot respect it./p –flag nameflagNoPersonalizedLearning value0x1000000 /!– Used to request that the IME never gointo fullscreen mode. Applications need to be aware that the flag is nota guarantee, and not all IMEs will respect it.pCorresponds to{link android.view.inputmethod.EditorInfo#IME_FLAG_NO_FULLSCREEN}. –flag nameflagNoFullscreen value0x2000000 /!– Like flagNavigateNext, butspecifies there is something interesting that a backward navigationcan focus on. If the user selects the IMEs facility to backwardnavigate, this will show up in the application as an actionPreviousat {link android.view.inputmethod.InputConnection#performEditorAction(int)InputConnection.performEditorAction(int)}.pCorresponds to{link android.view.inputmethod.EditorInfo#IME_FLAG_NAVIGATE_PREVIOUS}. –flag nameflagNavigatePrevious value0x4000000 /!– Used to specify that there is somethinginteresting that a forward navigation can focus on. This is like usingactionNext, except allows the IME to be multiline (withan enter key) as well as provide forward navigation. Note that someIMEs may not be able to do this, especially when running on a smallscreen where there is little space. In that case it does not need topresent a UI for this option. Like actionNext, if theuser selects the IMEs facility to forward navigate, this will show upin the application at{link android.view.inputmethod.InputConnection#performEditorAction(int)InputConnection.performEditorAction(int)}.pCorresponds to{link android.view.inputmethod.EditorInfo#IME_FLAG_NAVIGATE_NEXT}. –flag nameflagNavigateNext value0x8000000 /!– Used to specify that the IME does not needto show its extracted text UI. For input methods that may be fullscreen,often when in landscape mode, this allows them to be smaller and let partof the application be shown behind. Though there will likely be limitedaccess to the application available from the user, it can make theexperience of a (mostly) fullscreen IME less jarring. Note that whenthis flag is specified the IME may emnot/em be set up to be ableto display text, so it should only be used in situations where this isnot needed.pCorresponds to{link android.view.inputmethod.EditorInfo#IME_FLAG_NO_EXTRACT_UI}. –flag nameflagNoExtractUi value0x10000000 /!– Used in conjunction with a custom action, this indicates that theaction should not be available as an accessory button when theinput method is full-screen.Note that by setting this flag, there can be cases where the actionis simply never available to the user. Setting this generally meansthat you think showing text being edited is more important than theaction you have supplied.pCorresponds to{link android.view.inputmethod.EditorInfo#IME_FLAG_NO_ACCESSORY_ACTION}. –flag nameflagNoAccessoryAction value0x20000000 /!– Used in conjunction with a custom action,this indicates that the action should not be available in-line asa replacement for the enter key. Typically this isbecause the action has such a significant impact or is not recoverableenough that accidentally hitting it should be avoided, such as sendinga message. Note that {link android.widget.TextView} willautomatically set this flag for you on multi-line text views.pCorresponds to{link android.view.inputmethod.EditorInfo#IME_FLAG_NO_ENTER_ACTION}. –flag nameflagNoEnterAction value0x40000000 /!– Used to request that the IME should be capable of inputting ASCIIcharacters. The intention of this flag is to ensure that the usercan type Roman alphabet characters in a {link android.widget.TextView}used for, typically, account ID or password input. It is expected that IMEsnormally are able to input ASCII even without being told so (such IMEsalready respect this flag in a sense), but there could be some cases theyarent when, for instance, only non-ASCII input languages like Arabic,Greek, Hebrew, Russian are enabled in the IME. Applications need to beaware that the flag is not a guarantee, and not all IMEs will respect it.However, it is strongly recommended for IME authors to respect this flagespecially when their IME could end up with a state that has only non-ASCIIinput languages enabled.pCorresponds to{link android.view.inputmethod.EditorInfo#IME_FLAG_FORCE_ASCII}. –flag nameflagForceAscii value0x80000000 //attr2.2 继承InputMethodService.java的输入法应用覆盖onEvaluateFullscreenMode方法 覆盖onEvaluateFullscreenMode方法返false就可以了。如Android14上google输入法LatinImeGoogle.apk frameworks/base/core/java/android/inputmethodservice/InputMethodService.java /** Override this to control when the input method should run in* fullscreen mode. The default implementation runs in fullsceen only* when the screen is in landscape mode. If you change what* this returns, you will need to call {link #updateFullscreenMode()}* yourself whenever the returned value may have changed to have it* re-evaluated and applied.*/ public boolean onEvaluateFullscreenMode() {Configuration config getResources().getConfiguration();if (config.orientation ! Configuration.ORIENTATION_LANDSCAPE) {return false;}if (mInputEditorInfo ! null ((mInputEditorInfo.imeOptions EditorInfo.IME_FLAG_NO_FULLSCREEN) ! 0// If app window has portrait orientation, regardless of what display orientation// is, IME shouldnt use fullscreen-mode.|| (mInputEditorInfo.internalImeOptions EditorInfo.IME_INTERNAL_FLAG_APP_WINDOW_PORTRAIT) ! 0)) {return false;}return true; }