Android13 修改标题栏status_bar高度

2024-07-04  本文已影响0人  MrDemo

/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);
    }
上一篇下一篇

猜你喜欢

热点阅读