Android Completely transparent Status Bar?

前端 未结 28 2987
旧时难觅i
旧时难觅i 2020-11-22 14:10

I\'ve searched the documentation but only found this: Link. Which is used to make the bar translucent? What I\'m trying to do is to make t

28条回答
  •  一整个雨季
    2020-11-22 14:25

    THERE ARE THREE STEPS:

    1) Just use this code segment into your OnCreate method

      // FullScreen
      getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, 
      WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
    

    If you’re working on Fragment, you should put this code segment in your activity’s OnCreate method.

    2) Be sure to also set the transparency in /res/values-v21/styles.xml:

    @android:color/transparent
    

    Or you can set the transparency programmatically:

    getWindow().setStatusBarColor(Color.TRANSPARENT);
    

    3) In anyway you should add the code segment in styles.xml

    true
    

    NOTE: This method just works on API 21 and above.

提交回复
热议问题