实际项目维护中,华为手机测试过程软键盘弹起后,收起软键盘。页面没有渲染成功。经过长时间检查,终于解决。参考方案
try {
web();
ViewGroup.LayoutParams params = webView.getLayoutParams();
if (params instanceof ConstraintLayout.LayoutParams) {
ConstraintLayout.LayoutParams layoutParams = (ConstraintLayout.LayoutParams) params;
decorView = getActivity().getWindow().getDecorView();
if (decorView != null) {
// 设置全局布局监听器
globalLayoutListener = new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
if (webView != null && decorView.getViewTreeObserver().isAlive()) {
Rect rect = new Rect();
decorView.getWindowVisibleDisplayFrame(rect);
int screenHeight = decorView.getRootView().getHeight()