junixapp/XPopup

getStatusBarHeight 获取高度有问题

Closed this issue · 1 comments

XPopup版本
2.9.15

手机系统和型号
荣耀20Pro Android 10(鸿蒙2.0.0)

描述你的问题
在使用 DrawerPopupView 作侧拉弹窗时,设置了 hasStatusBarShadow 发现无效,截图如下:
image
经排查发现:

    @Override
    protected void dispatchDraw(Canvas canvas) {
        super.dispatchDraw(canvas);
        if (popupInfo!=null && popupInfo.hasStatusBarShadow) {
            if (shadowRect == null) {
                shadowRect = new Rect(0, 0, getMeasuredWidth(), getStatusBarHeight());
            }
            paint.setColor((Integer) argbEvaluator.evaluate(mFraction, defaultColor, getStatusBarBgColor()));
            canvas.drawRect(shadowRect, paint);
        }
    }

debug 运行时 getStatusBarHeight() 获取到的高度为 0, 所以绘制无效,因此我尝试重写了getStatusBarHeight 方法,借助ImmersionBar 实现如下:

override fun getStatusBarHeight(): Int {
	return ImmersionBar.getStatusBarHeight(context)
} 

运行时正常,截图如下:
7fd5a3bee2728a037c1fdb344b2ab5cf

希望大佬有时间可以兼容修改一下

@Heart-Beats 更新到2.9.16即可