Coordinatorlayout adjustresize not working

前端 未结 9 586
傲寒
傲寒 2020-12-08 15:32

MY CODE (and more): I have a Coordinator Layout as follows



        
9条回答
  •  一整个雨季
    2020-12-08 15:50

    A shortened version from KeyboardUtil, add this to your activity:

    getWindow().getDecorView().getViewTreeObserver()
            .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        public void onGlobalLayout() {
            Rect r = new Rect();
            getWindow().getDecorView().getWindowVisibleDisplayFrame(r);
            rootView.setPadding(0, 0, 0,
                    activity.getResources().getDisplayMetrics().heightPixels - r.bottom);
        }
    });
    

提交回复
热议问题