以编程方式设置windowlightstatusbar属性 [英] set windowlightstatusbar property programmatically

查看:804
本文介绍了以编程方式设置windowlightstatusbar属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您知道,我们可以通过以下代码从xml设置 windowLightStatusBar

As you know we can set the windowLightStatusBar from xml by following codes.

<item name="android:windowLightStatusBar">true</item>

我需要通过编程将此属性从true更改为false或将false更改为true。有办法实现吗?

i need to change this attribute true to false or false to true by programmatically. Is there a way to achive it?

推荐答案

如果要更改图标颜色,请设置此项

set this if you want to change icons colors

.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_‌​BAR);

并重置为默认值,将其设置为

and to reset to default set this

.setSystemUiVisibility(0);

但是如果您想更改statusBar的背景颜色,请使用此

but if you want to change background color of statusBar use this

getWindow.setStatusBarColor(ContextCompat.getColor(activity,R.color.my_statusbar_color));

这篇关于以编程方式设置windowlightstatusbar属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆