简体   繁体   English

如何使状态栏完全白色?

[英]How to make Status bar completely white?

At different times when using my app, the color of the status bar changes, the right would be white as in the first image, but at times it turns gray.在使用我的应用程序的不同时间,状态栏的颜色会发生变化,右边会像第一张图片一样是白色的,但有时它会变成灰色。 What can this be?这可以是什么? Android bug?安卓漏洞? Here it is completely white Here it is already gray, after entering the app time after这里是全白这里已经是灰色了,进入app时间后

styles.xml:样式.xml:

<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
    <item name="colorPrimary">@color/primary</item>
    <item name="android:windowLightStatusBar">true</item>
    <item name="colorPrimaryDark">#ffffff</item>
    <item name="colorAccent">@color/accent</item>

</style>    

To change the color for above api 21 just add this to your styles.xml要更改上述api 21的颜色,只需将其添加到您的styles.xml

<item name="android:statusBarColor">@color/statusBarColor</item>

if you want to have a light color for the status bar, add this line too如果您想为状态栏设置浅色,也请添加此行

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

Edit :编辑 :

if it keeps changing color , so try to change your color in you activities this way :如果它一直在改变颜色,那么尝试以这种方式改变你活动中的颜色:

 if (Build.VERSION.SDK_INT >= 21) {
    getWindow().setNavigationBarColor(ContextCompat.getColor(this, R.color.white)); // Navigation bar the soft bottom of some phones like nexus and some Samsung note series  
    getWindow().setStatusBarColor(ContextCompat.getColor(this,R.color.white)); //status bar or the time bar at the top
  }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使状态栏带有黑色图标的白色背景? - How can I make the status bar white background with black icon? 隐藏状态栏android时一瞥白条(如何使其像Whatsapp状态一样) - A glimpse of white bar when hiding status bar android (How to make it like Whatsapp status) 滚动时 AppBar 未完全隐藏在状态栏中 - AppBar not hiding completely in status bar when scrolling 如何使用xml文件使状态栏和导航栏透明 - How to make status bar and navigation bar transparent using xml file 如何在不重叠状态栏/导航栏和状态栏颜色的情况下使DialogFragment全屏显示? - How to make DialogFragment fullscreen without overlapping status bar/navigation bar and mantain status bar color? 工具栏和状态栏之间的空白 - white space between toolbar and status bar 如何在我的Cordova应用程序中将状态栏设置为白色背景和黑色文本(黑色图标) - How to set Status bar to white background and black text (black icon) in my cordova app 状态栏,如何使我的线条,椭圆和rects可见? - Status bar , how to make my lines,ovals and rects visible? 如何使状态栏透明和文本颜色为灰色? - How to make the status bar transparent and the text color is grey? 无法使状态栏为半透明 - Cannot make status bar translucent
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM