@@ -0,0 +1,2474 @@
+package com.charon.softinputdemo;%0A%0Aimport android.app.Activity;%0Aimport android.content.Context;%0Aimport android.graphics.Rect;%0Aimport android.view.View;%0Aimport android.view.ViewTreeObserver;%0Aimport android.view.inputmethod.InputMethodManager;%0A%0Apublic class SoftKeyboardUtil %7B%0A%0A    public static void observeSoftKeyBoard(Activity activity, final OnSoftKeyBoardHideListener listener) %7B%0A        final View decorView = activity.getWindow().getDecorView();%0A        decorView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() %7B%0A            @Override%0A            public void onGlobalLayout() %7B%0A                Rect rect = new Rect();%0A                decorView.getWindowVisibleDisplayFrame(rect);%0A                int displayHight = rect.bottom - rect.top;%0A                int hight = decorView.getHeight();%0A                boolean hide = (double) displayHight / hight %3E 0.8;%0A                listener.onSoftKeyBoardVisible(!hide);%0A            %7D%0A        %7D);%0A    %7D%0A%0A%0A    public static void showKeyboard(Context context, View view) %7B%0A        if (context == null) %7B%0A            return;%0A        %7D%0A        context = context.getApplicationContext();%0A        InputMethodManager mInputMethodManager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);%0A        mInputMethodManager.showSoftInput(view, InputMethodManager.RESULT_SHOWN);%0A//        mInputMethodManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);%0A    %7D%0A%0A    public static void hideKeyboard(Context context, View view) %7B%0A        if (context == null %7C%7C view == null) %7B%0A            return;%0A        %7D%0A        context = context.getApplicationContext();%0A        InputMethodManager mInputMethodManager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);%0A        mInputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.RESULT_UNCHANGED_SHOWN);%0A    %7D%0A%0A%0A    public static void hideKeyboard(Activity activity) %7B%0A        InputMethodManager imm = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);%0A%0A        View view = activity.getCurrentFocus();%0A        if (view == null) %7B%0A            view = new View(activity);%0A        %7D%0A        imm.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.RESULT_UNCHANGED_SHOWN);%0A    %7D%0A%0A    public interface OnSoftKeyBoardHideListener %7B%0A        void onSoftKeyBoardVisible(boolean visible);%0A    %7D%0A%0A%7D%0A

Add SoftKeyboardUtil