软键盘弹起问题

2019-07-27  本文已影响0人  geaosu

mRoot = getActivity().getWindow().getDecorView();
mRoot.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
    @Override
    public void onGlobalLayout() {
        Rect rect = new Rect();
        mRoot.getWindowVisibleDisplayFrame(rect);
        int rootInvisibleHeight = mRoot.getRootView().getHeight()-rect.bottom;
        if(rootInvisibleHeight>100){
            //显示
            footerView.setVisibility(View.GONE);
        }else{
            //隐藏
            footerView.setVisibility(View.VISIBLE);
        }
    }
});


上一篇下一篇

猜你喜欢

热点阅读