Android13 修改标题栏status_bar高度

/home/wp/QZ-T527/T527_Android13_V1.0_20231205/android/frameworks/base/core/res/res/values/dimens.xml
修改标签status_bar_height_default

<dimen name="status_bar_height_default">60dp</dimen>

代码跟踪,当我只修改status_bar_height与status_bar.xml后我发现并没有发生改变,最后发现是在
/home/wp/QZ-T527/T527_Android13_V1.0_20231205/android/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java中发现进行了动态的赋值

 private void updateStatusBarHeight() {
        final int waterfallTopInset =
                mDisplayCutout == null ? 0 : mDisplayCutout.getWaterfallInsets().top;
        ViewGroup.LayoutParams layoutParams = getLayoutParams();
        mStatusBarHeight = SystemBarUtils.getStatusBarHeight(mContext);
      //省略部分代码
    }

跟踪SystemBarUtils类发现使用的是status_bar_height_default的值

    public static int getStatusBarHeight(Resources res, DisplayCutout cutout) {
        final int defaultSize = res.getDimensionPixelSize(R.dimen.status_bar_height_default);
        final int safeInsetTop = cutout == null ? 0 : cutout.getSafeInsetTop();
        final int waterfallInsetTop = cutout == null ? 0 : cutout.getWaterfallInsets().top;
        // The status bar height should be:
        // Max(top cutout size, (status bar default height + waterfall top size))
        return Math.max(safeInsetTop, defaultSize + waterfallInsetTop);
    }
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容