Hide navigation bar:

Just add the following two lines in the Themes (theme file)

        <item name="android:windowFullscreen">true</item>
        <item name="android:windowContentOverlay">@null</item>
Copy the code

EditView Focus control:

After clicking EditView, empty the Hint

Ideas: Simply add a focusChangeListener to the EditView. This method has a hasFocus attribute that is true when the View is focused, so that you can use if to determine the focus state of the current control, and then hide the Hint text based on the shift in focus.

TODO: Create a custom EditView class, extendsEditView, and pull out the listener function body as a function, and put the function in the custom class.

 et_user.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                if (hasFocus){
                    et_user.setHint("");
                }
                else{
                    et_user.setHint("Please enter user name"); }}});Copy the code

When you click the blank, EditView loses focus and hides the keyboard

Clear Focus (EditView, EditView, EditView, EditView

 // Causes the editText to lose focus when it clicks outside
    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
        if (ev.getAction() == MotionEvent.ACTION_DOWN) {
            View v = getCurrentFocus();
            if (isShouldHideInput(v, ev)) {// Click outside the editText control
                InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                if(imm ! =null) {
                    assertv ! =null;
                    KeyBoardUtil.closeKeyboard(v);// Soft keyboard tool class
                    if(editText ! =null) { editText.clearFocus(); }}}return super.dispatchTouchEvent(ev);
        }
        // Necessary, otherwise all components will not have TouchEvents
        return getWindow().superDispatchTouchEvent(ev) || onTouchEvent(ev);
    }

    EditText editText = null;

    public boolean isShouldHideInput(View v, MotionEvent event) {
        if(v ! =null && (v instanceof EditText)) {
            editText = (EditText) v;
            int[] leftTop = {0.0};
            // Get the current location of the input box
            v.getLocationInWindow(leftTop);
            int left = leftTop[0];
            int top = leftTop[1];
            int bottom = top + v.getHeight();
            int right = left + v.getWidth();
            return! (event.getX() > left && event.getX() < right && event.getY() > top && event.getY() < bottom); }return false;
    }
Copy the code