可以在点击返回按钮的时候隐藏
就在返回按钮的点击事件里加:
InputMethodManager imm = (InputMethodManager) _mActivity.getSystemService(Context.INPUT_METHOD_SERVICE);
// 隐藏软键盘
imm.hideSoftInputFromWindow(_mActivity.getWindow().getDecorView().getWindowToken(), 0);
就可以了
下面是别人的:
package com.reapal.util;
import android.app.Activity;
import android.content.Context;
import android.view.inputmethod.InputMethodManager;
/**
* /**
* 创 建 者:下一页5(轻飞扬)
* 创建时间:2018/4/18.11:25
* 关于键盘方法的所有工具类
*/
public class KeyboardUtils {
/**
* 隐藏键盘的方法
*
* @param context
*/
public static void hideKeyboard(Activity context) {
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
// 隐藏软键盘
imm.hideSoftInputFromWindow(context.getWindow().getDecorView().getWindowToken(), 0);
}
}
来源:CSDN
原文:https://blog.csdn.net/xiayiye5/article/details/79987368