Android M Light and Dark status bar programmatically - how to make it dark again?

前端 未结 10 1684
自闭症患者
自闭症患者 2020-12-24 10:49

In the Android M we have ability to make status bar icons dark. To do that we can specify attribute in the theme\'s xml:



        
10条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-24 11:38

    To change to light status bar use:-

     if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) 
         activity?.window?.decorView?.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
    
    

    To change back to dark status bar :-

     if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) 
         activity?.window?.decorView?.systemUiVisibility = 0
    

提交回复
热议问题