Home > Mobile >  Android App in full screen mode system virtual keyboard input method showed that when together with
Android App in full screen mode system virtual keyboard input method showed that when together with

Time:10-04

goal is to want to hide in display system input method system at the bottom of the menu
In the android emulator running situation is as follows:

Below is the activity of rewriting method of display system input method
 
@ Override
Public Boolean dispatchTouchEvent (MotionEvent ev) {
If (ev) getAction ()==MotionEvent. ACTION_DOWN) {
The View v=getCurrentFocus ();
If (isShouldHideInput (v, ev)) {
InputMethodManager imm=(InputMethodManager) getSystemService (Context. INPUT_METHOD_SERVICE);
If (imm!=null) {
Assert v!=null;
Imm. HideSoftInputFromWindow (v.g etWindowToken (), InputMethodManager. HIDE_NOT_ALWAYS);
V. etClickable (true);
V. etFocusable (true);
V. etFocusableInTouchMode (true);
V.r equestFocusFromTouch ();

The e (TAG, "dispatchTouchEvent: 111111111111111111");
}
}
The e (TAG, "dispatchTouchEvent: 22222222222222222222222");
Return super. DispatchTouchEvent (ev);
}
The e (TAG, "dispatchTouchEvent: 333333333333333333333");
//necessary, otherwise all the components are there won't be TouchEvent
Return getWindow (). SuperDispatchTouchEvent (ev) | | onTouchEvent (ev);
}

Public Boolean isShouldHideInput (View v, MotionEvent event) {
If (v!=null & amp; & (v instanceof EditText)) {
Int [] leftTop={0, 0};
//to get current location input box location
V.g etLocationInWindow (leftTop);
Int left=leftTop [0];
Int top=leftTop [1].
Int bottom=top + v.g etHeight ();
Int right=left + v.g etWidth ();
The return! (event. GetX () & gt; Left & amp; & Event. The getX () & lt; Right
& & Event. GetY () & gt; Top & amp; & Event. GetY () & lt; Bottom);
}
return false;
}

CodePudding user response:

A ah, bosses

CodePudding user response:


/* ** banned system soft keyboard 
*/
Public void hideSoftInputMethod () {
MActivity. GetWindow (). SetSoftInputMode (WindowManager. LayoutParams. SOFT_INPUT_STATE_ALWAYS_HIDDEN);
Int currentVersion.=the android OS. Build. VERSION. SDK_INT;
String methodName=null;
If (currentVersion & gt; 16)={
//4.2
MethodName="setShowSoftInputOnFocus";
} else if (currentVersion & gt; 14)={
//4.0
MethodName="setSoftInputShownOnFocus";
}
If (methodName==null) {
MEdit. SetInputType (InputType. TYPE_NULL);
} else {
Class CLS=EditText. Class;
Method setShowSoftInputOnFocus;
Try {
SetShowSoftInputOnFocus=CLS. GetMethod (methodName, Boolean. Class);
SetShowSoftInputOnFocus. SetAccessible (true);
SetShowSoftInputOnFocus. Invoke (mEdit, false);
} the catch (NoSuchMethodException e) {
MEdit. SetInputType (InputType. TYPE_NULL);
e.printStackTrace();
} the catch (IllegalAccessException e) {
e.printStackTrace();
} the catch (IllegalArgumentException e) {
e.printStackTrace();
} the catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}

Their reference

CodePudding user response:

The
reference
/* *
* banned system soft keyboard
*/
Public void hideSoftInputMethod () {
MActivity. GetWindow (). SetSoftInputMode (WindowManager. LayoutParams. SOFT_INPUT_STATE_ALWAYS_HIDDEN);
Int currentVersion.=the android OS. Build. VERSION. SDK_INT;
String methodName=null;
If (currentVersion & gt; 16)={
//4.2
MethodName="setShowSoftInputOnFocus";
} else if (currentVersion & gt; 14)={
//4.0
MethodName="setSoftInputShownOnFocus";
}
If (methodName==null) {
MEdit. SetInputType (InputType. TYPE_NULL);
} else {
Class CLS=EditText. Class;
Method setShowSoftInputOnFocus;
Try {
SetShowSoftInputOnFocus=CLS. GetMethod (methodName, Boolean. Class);
SetShowSoftInputOnFocus. SetAccessible (true);
SetShowSoftInputOnFocus. Invoke (mEdit, false);
} the catch (NoSuchMethodException e) {
MEdit. SetInputType (InputType. TYPE_NULL);
e.printStackTrace();
} the catch (IllegalAccessException e) {
e.printStackTrace();
} the catch (IllegalArgumentException e) {
e.printStackTrace();
} the catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}

Their reference

Bosses of this method is to hide the system input method, I just want to in the display system input method does not display the system menu bar, after the return is below the input method, homepage, virtual buttons and menu, is there a way to?
  • Related