Android statusbar overlay with ActionBar

后端 未结 4 787
猫巷女王i
猫巷女王i 2021-02-07 03:39

I know that I can make the ActionBar overlay using requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY)
and can toggle/show the status bar in my screen (by switch

相关标签:
4条回答
  • 2021-02-07 04:03

    Put this method in onCreate() method activity:

    getWindow().getDecorView().setSystemUiVisibility(
    View.SYSTEM_UI_FLAG_LAYOUT_STABLE
    | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
    

    refer: link

    0 讨论(0)
  • 2021-02-07 04:06

    so apparently, you can do this in Jellybean. google includes two examples in the api docs. here is a link: http://developer.android.com/reference/android/view/View.html#setSystemUiVisibility%28int%29

    summary: use setSystemUiVisibility on a view to toggle visibility (on jellybean+).

    0 讨论(0)
  • 2021-02-07 04:22

    It's not perfect, but this is how I have achieved what you want:

    In onCreate:

    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);

    Then:

    private void hideStatusBar() {
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
    
    }
    
    private void showStatusBar() {
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    
    }
    

    I also have a style on the activity with the following:

     <style name="readingStyle" parent="@style/Theme.Sherlock">
         <item name="android:windowActionBarOverlay">true</item>  
         <item name="windowActionBarOverlay">true</item>       
     </style> 
    

    Your activity will shift down when the status bar shows, but I don't think it's too noticeable.

    0 讨论(0)
  • 2021-02-07 04:23

    Why you dont make it in the Manifest

    android:theme="@android:style/Theme.Black.NoTitleBar"
    

    than you have no statusbar and more space for the Actionbar??

    0 讨论(0)
提交回复
热议问题