此文章主要是通过Hierarchy View来了解statusbar的具体结构体系
一.如何打开Hierachy View
首先在SDK/Tools文件夹下打开Monitor,按照如下操作打开Hierachy View。
StatusBarWindowView:状态栏根布局
StatusBarWindowView继承了FrameLayout布局
1)重写了onApplyWindowInsets(WindowInsets windowInsets)方法
WindowInsets提供窗口中可供应用程序使用的区域,覆盖onApplyWindowInsets()方法就可以控制可用于View的窗口区域。调用applyMargins()方法,设置窗口区域里控件的外边距。
2)私有方法applyMargins()
设置子控件的外边距
3)静态方法paddingNeededForCutoutAndRoundedCorner(…)
计算状态栏相关视图所需的内边距,例如PhoneStatusBar,
QuickStatusBarHeader和KeyguardStatusBarView)
4)静态方法cornerCutoutMargins(…)
调用了statusBarCornerCutoutMargins()方法,作用是计算在纵向模式下外边距
5)静态方法statusBarCornerCutoutMargins(…)
作用是计算给定方向(exactRotation)上的外边距
PhoneStatusBarView:主要用于显示系统状态,通知等,主要包括notification icons和status bar icons
HeadsUpStatusBarView主要是运营商相关信息的自定义View
StatusBarIconView通知栏图标类
BatteryMeterView 电池相关的自定义View