Home > other >  Problems setting up the new people for help ~ ~ ~ about AndroidManifest
Problems setting up the new people for help ~ ~ ~ about AndroidManifest

Time:09-21

Unity3d create android game after the chat box be soft keyboard, then to search also changed the AndroidManifest but has no effect, still keep out chat box, main Activity code the great god help take a look at the following trouble is wrong ~ thank you ~


<meta - data android: name="android. App. Lib_name" android: value="https://bbs.csdn.net/topics/unity"/& gt;
<meta - data android: name="unityplayer ForwardNativeEventsToDalvik" android: value="https://bbs.csdn.net/topics/false"/& gt;




Thank you very much ~

CodePudding user response:

Android soft keyboard display mode:

Android defines an attribute that windowSoftInputMode name, use it can make the program can adjust the way of control activities in the main window, we can in AndroidManifet. XML to set of activities, such as: Android: windowSoftInputMode="stateUnchanged | adjustPan"

The optional attribute values has two parts, part of the state of the soft keyboard control, the other part is the adjustment of the main window, the former part of this article do not discuss, please consult the android documentation,

Model, a compression mode

If set to adjustResize windowSoftInputMode's value, then the Activity the main window is always adjust the size in order to set aside the space of the soft keyboard,

We through a piece of code to test, when we set the attribute, pop-up input method, the system do,

Model 2, translational mode

WindowSoftInputMode value if set to adjustPan, then the Activity to the main window is not to adjust the size of the screen to leave the space of the soft keyboard, on the contrary, the content of the current window will automatically move to the current focus is never covered by the keyboard and users can always see the content of the input part, this is not usually expect than resizing, because the user may close the soft keyboard to get interactions with covered content,

In the example above, we will AndroidManifest. XML attribute changes: android: windowSoftInputMode="adjustPan"

Three automatic mode

WindowSoftInputMode when the attribute is set to adjustUspecified, it is not specify whether the Activity is the main window resize to leave the space of the soft keyboard, or whether the contents of the window to get the current focus is visible on the screen, the system will automatically select the mode one mainly depends on whether the content of the window has any layout views can scroll their contents, if there is such a view, the window will adjust the size, this assumption can make the content of the rolling window visible in a smaller area, this is the behavior of the main window of the default Settings,

That is to say, the system automatically decided to adopt the translational mode or compression mode, deciding factor is whether the content can scroll,

Soft keyboard switch:

InputMethodManager imm=(InputMethodManager) getSystemService (Context. INPUT_METHOD_SERVICE);
//get the InputMethodManager instance
If (imm) isActive ()) {
//if this
Imm. ToggleSoftInput (InputMethodManager SHOW_IMPLICIT, InputMethodManager HIDE_NOT_ALWAYS);
//close the soft keyboard, open in the same way, this method is to switch between open and closed
}

Close the soft keyboard

If (getCurrentFocus ()!=null)
{
((InputMethodManager) getSystemService (INPUT_METHOD_SERVICE))
HideSoftInputFromWindow (getCurrentFocus ()
GetWindowToken (),
InputMethodManager. HIDE_NOT_ALWAYS);
}
  • Related