rect.bottom是10000,rect.top是-10000,这是咋回事啊???

ViewTreeObserver.OnGlobalLayoutListener onGlobalLayoutListener=new ViewTreeObserver.OnGlobalLayoutListener() {

    @Override
    public void onGlobalLayout() {
        Rect rect=new Rect();
        ((AppCompatActivity)mContext).getWindow().getDecorView().getWindowVisibleDisplayFrame(rect);
        int screenHeight=getRootView().getHeight();
        int heightDiff=screenHeight-(rect.bottom-rect.top)-UIUtils.dipToPx(48);
        if(heightDiff>100){
            emptyView.setVisibility(VISIBLE);
            LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) emptyView.getLayoutParams();
            params.height=heightDiff;
            emptyView.setLayoutParams(params);
        }else{
            emptyView.setVisibility(GONE);
        }

    }
};

在manifest中android:configChanges="orientation|keyboardHidden|screenSize"设置了后,竖屏的时候,rect.bottom和rect.top是对的;横屏的时候,rect.bottom是10000,rect.top是-10000,这是咋回事啊????

阅读 868
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题