quick_status_bar_expanded_header.xml(QuickStatusBarHeader根控件)的背景颜色
第一次下滑
绿色是QuickQSPanel控件的背景颜色
蓝色是quick_status_bar_expanded_header.xml(QuickStatusBarHeader根控件)的背景颜色
橙色是qs_panel.xml(QSContainerImpl根控件)占用背景效果
第二次下滑
绿色消失不见
蓝色是quick_status_bar_expanded_header.xml(QuickStatusBarHeader根控件)的背景颜色
紫色是QSPanel控件的背景颜色
橙色是qs_panel.xml(QSContainerImpl根控件)的背景颜色
QuickStatusBarHeader控件自定义自己高度的效果
QuickStatusBarHeader可以看到在updateResources()方法有配置自己的高度
xml
<dimen name="cus_quick_status_bar_header_height">300dp</dimen>
java
void updateResources() {
Resources resources = mContext.getResources();
boolean largeScreenHeaderActive =
LargeScreenUtils.shouldUseLargeScreenShadeHeader(resources);
boolean gone = largeScreenHeaderActive || mUseCombinedQSHeader || mQsDisabled;
mStatusIconsView.setVisibility(gone ? View.GONE : View.VISIBLE);
mDatePrivacyView.setVisibility(gone ? View.GONE : View.VISIBLE);
mConfigShowBatteryEstimate = resources.getBoolean(R.bool.config_showBatteryEstimateQSBH);
mRoundedCornerPadding = resources.getDimensionPixelSize(
R.dimen.rounded_corner_content_padding);
int qsOffsetHeight = SystemBarUtils.getQuickQsOffsetHeight(mContext);
mDatePrivacyView.getLayoutParams().height =
Math.max(qsOffsetHeight, mDatePrivacyView.getMinimumHeight());
mDatePrivacyView.setLayoutParams(mDatePrivacyView.getLayoutParams());
mStatusIconsView.getLayoutParams().height =
Math.max(qsOffsetHeight, mStatusIconsView.getMinimumHeight());
mStatusIconsView.setLayoutParams(mStatusIconsView.getLayoutParams());
ViewGroup.LayoutParams lp = getLayoutParams();
if (mQsDisabled) {
lp.height = mStatusIconsView.getLayoutParams().height;
} else {
lp.height = WRAP_CONTENT;
//自定义自己设置的高度
int cusHeight = getResources().getDimensionPixelSize(R.dimen.cus_quick_status_bar_header_height);
lp.height = cusHeight;
}
Log.i("cusTAG", "updateResources height: "+lp.height);
setBackgroundResource(android.R.color.holo_blue_light);
setLayoutParams(lp);
int textColor = Utils.getColorAttrDefaultColor(mContext, android.R.attr.textColorPrimary);
if (textColor != mTextColorPrimary) {
int textColorSecondary = Utils.getColorAttrDefaultColor(mContext,
android.R.attr.textColorSecondary);
mTextColorPrimary = textColor;
mClockView.setTextColor(textColor);
if (mTintedIconManager != null) {
mTintedIconManager.setTint(textColor);
}
mBatteryRemainingIcon.updateColors(mTextColorPrimary, textColorSecondary,
mTextColorPrimary);
}
MarginLayoutParams qqsLP = (MarginLayoutParams) mHeaderQsPanel.getLayoutParams();
if (largeScreenHeaderActive) {
qqsLP.topMargin = mContext.getResources()
.getDimensionPixelSize(R.dimen.qqs_layout_margin_top);
} else if (!mUseCombinedQSHeader) {
qqsLP.topMargin = qsOffsetHeight;
} else {
qqsLP.topMargin = mContext.getResources()
.getDimensionPixelSize(R.dimen.large_screen_shade_header_min_height);
}
mHeaderQsPanel.setLayoutParams(qqsLP);
updateBatteryMode();
updateHeadersPadding();
updateAnimators();
updateClockDatePadding();
}
onFinishInflate()调用到updateResources()方法
java
@Override
protected void onFinishInflate() {
super.onFinishInflate();
mHeaderQsPanel = findViewById(R.id.quick_qs_panel);
mDatePrivacyView = findViewById(R.id.quick_status_bar_date_privacy);
mStatusIconsView = findViewById(R.id.quick_qs_status_icons);
mQSCarriers = findViewById(R.id.carrier_group);
mContainer = findViewById(R.id.qs_container);
mIconContainer = findViewById(R.id.statusIcons);
mPrivacyChip = findViewById(R.id.privacy_chip);
mDateView = findViewById(R.id.date);
mClockDateView = findViewById(R.id.date_clock);
mClockIconsSeparator = findViewById(R.id.separator);
mRightLayout = findViewById(R.id.rightLayout);
mDateContainer = findViewById(R.id.date_container);
mPrivacyContainer = findViewById(R.id.privacy_container);
mClockContainer = findViewById(R.id.clock_container);
mClockView = findViewById(R.id.clock);
mDatePrivacySeparator = findViewById(R.id.space);
// Tint for the battery icons are handled in setupHost()
mBatteryRemainingIcon = findViewById(R.id.batteryRemainingIcon);
updateResources();
Configuration config = mContext.getResources().getConfiguration();
setDatePrivacyContainersWidth(config.orientation == Configuration.ORIENTATION_LANDSCAPE);
// QS will always show the estimate, and BatteryMeterView handles the case where
// it's unavailable or charging
mBatteryRemainingIcon.setPercentShowMode(BatteryMeterView.MODE_ESTIMATE);
mIconsAlphaAnimatorFixed = new TouchAnimator.Builder()
.addFloat(mIconContainer, "alpha", 0, 1)
.addFloat(mBatteryRemainingIcon, "alpha", 0, 1)
.build();
}
简单的布局文件层级分析
status_bar_expanded.xml(NotificationPanelView根控件)
- NotificationsQuickSettingsContainer
- qs_panel.xml(QSContainerImpl根控件)
- NonInterceptingScrollView
- QSPanel,第二次下滑时快捷设置区域
- quick_status_bar_expanded_header.xml(QuickStatusBarHeader根控件)
- RelativeLayout
- QuickQSPanel,第一次下滑快捷设置区域,第二次下滑会被隐藏掉
- RelativeLayout
- NonInterceptingScrollView
- qs_panel.xml(QSContainerImpl根控件)