PopupWindow留白,沉侵式状态栏下PopupWindow遮盖不全

 

 

如图所示

 Rect visibleFrame = new Rect();
            anchor.getGlobalVisibleRect(visibleFrame);
            int height = anchor.getResources().getDisplayMetrics().heightPixels - visibleFrame.bottom;
            setHeight(height);

int[] location = new int[2];
            anchorView.getLocationOnScreen(location);
            int tempHeight = getHeight();
            if (tempHeight == WindowManager.LayoutParams.MATCH_PARENT || getScreenHeight(anchorView.getContext()) <=
                    tempHeight) {
                setHeight(getScreenHeight(anchorView.getContext()) - location[1] - getHeight());
            }
            super.showAsDropDown(anchorView, Gravity.NO_GRAVITY, xoff, yoff);
            super.update();
都几把不管用,

这是什么原因造成的:主要是popupwind的页面测量不准造成的

解决方案1:

(老子就要自己写,不想用第三方)

 

    @Override
    public void showAsDropDown(View anchor, int xoff, int yoff) {
        if (Build.VERSION.SDK_INT >= 24) {
            Rect rect = new Rect();
            anchor.getGlobalVisibleRect(rect);
            Activity activity = (Activity) anchor.getContext();
            Rect outRect1 = new Rect();
            activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(outRect1);
            int h = outRect1.height() - rect.bottom+ ScreenUtils.getStatusBarHeight();
//            int h = anchor.getResources().getDisplayMetrics().heightPixels - rect.bottom;
            setHeight(h);
        }
        super.showAsDropDown(anchor, xoff, yoff);
    }

其中ScreenUtils是第三方的,沉侵式状态栏

implementation 'com.jaeger.statusbarutil:library:1.5.1'

第二种就是采用第三方

这三个都能用,很完美,能上能下,能前能后,动作多花样多,包顾客满意

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值