Keyboard input in Android is the most common and direct means of user input interaction, and there are a few things that can improve the user experience with regard to keyboard input.
First: Pop up the keyboard to move up the whole page, so that the keyboard does not obscure the control, you need to set the Windowsoftinputmode property of the activity in Androidmanifest
Statevisible
Set to this property, you can summon the soft keyboard, even if there is no input box on the interface can be forced to summon out
Adjustresize
This property indicates that the activity's main window is always resized to ensure that the soft keyboard displays space.
The effect is as follows:
<Activity Android: Name=". Activity. Loginactivity " Android: windowsoftinputmode="Statevisible|adjustresize" Android: label="@string/title_activity_login" Android: screenorientation="Portrait"></Activity>
Second: When there are multiple input controls on the page, the input control focus switch requires the user to click on the control switch, the experience is not very good, you can change the keyboard return to the "next" button, directly switch the cursor focus to the next input control. Set in the layout file
Android : imeoptions= "Actionnext" Android : singleline= "true"
can be
As shown
Third: When submitting the form, you can click the Submit button to submit, or the last edittext to get the focus when the key to set the keyboard return to send keys, so click on the keyboard key to automatically handle the logic of the submission form.
setting is also simple, the input control layout file adds two properties as follows:
Android : imeoptions= "Actionsend" Android : singleline= "true"
The logic for handling the response is detected in activity when the keyboard return is pressed
Mpassword.Setonkeylistener (NewView.onkeylistener() {@Override Public BooleanOnKey (Viewv,intKeyCode,KeyEventEvent) {if(KeyCode== KeyEvent.Keycode_enter) { ((Inputmethodmanager) Getsystemservice (Input_method_service)).Hidesoftinputfromwindow (loginactivity. This.Getcurrentfocus ().Getwindowtoken (),Inputmethodmanager.hide_not_always);if(Textutil.IsEmpty(Mpassword.GetText ().ToString ())) {Toastutil.getinstance().Show"Please enter your password"); }Else{Login (Musername.GetText ().ToString (),Mpassword.GetText ().ToString ()); } }return False; }});
As shown in the following:
Four: Change the ENTER key to search button, layout file EditText Add the following two properties:
Android : singleline= "true" Android : imeoptions= "Actionsearch"
the hit check on the ENTER key is the same as the top
The example diagram is as follows:
Android Development using the Imeoptions property to change the keyboard return to the search function keys "Improve user input experience"