Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问为什么可以设置状态栏的颜色 #13

Open
coolBreezes opened this issue Jul 20, 2018 · 1 comment
Open

请问为什么可以设置状态栏的颜色 #13

coolBreezes opened this issue Jul 20, 2018 · 1 comment

Comments

@coolBreezes
Copy link
Contributor

群主,看了您的源码,有个地方不是很明白,
在处理沉浸式的时候,viewStatusBarFill 布局是如何放到状态栏上面呢,
放到状态栏上面的布局为什么不会影响状态栏的显示呢

if (fillStatusBar && supportStatusBarLightMode) {
int statusBarHeight = AppUtils.getStatusBarHeight(context);
viewStatusBarFill = new View(context);
viewStatusBarFill.setId(AppUtils.generateViewId());
viewStatusBarFill.setBackgroundColor(statusBarColor);
LayoutParams statusBarParams = new LayoutParams(MATCH_PARENT, statusBarHeight);
statusBarParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
addView(viewStatusBarFill, statusBarParams);
}

@wuhenzhizao
Copy link
Owner

wuhenzhizao commented Jul 20, 2018

android4.4之后,可以修改WindowManager让decorView中的内容进入状态栏。
这里自定义了一个高度和状态栏一样的View,放在原来状态栏的位置,通过修改View的背景颜色,
来达到修改状态栏颜色的目的。
官方API和第三方库在某些android版本之后都可以直接修改状态栏颜色了,
不过只支持纯色,如果想要实现渐变等效果,还是有点麻烦,这正是这个库的特色了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants