1

I have a full screen Activity, here is all the related code on how I make it fullscreen:


Manifest.xml

<activity
    android:name=".Player"
    android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen.player" />

styles.xml

<style name="Theme.AppCompat.Light.NoActionBar.FullScreen.player" parent="@style/Theme.AppCompat.Light.NoActionBar">
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowActionBar">false</item>
    <item name="android:windowFullscreen">true</item>
    <item name="android:windowContentOverlay">@null</item>
</style>

Activity onCreate

requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

I then display a BottomSheetDialog, as shown below:

bottomSheetDialog = new BottomSheetDialog(this);
bottomSheetDialog.setContentView(dialogView);
bottomSheetDialog.show();

The problem I have is when I show the BottomSheetDialog, the StatusBar gets shown as well.

I have noticed that the StatusBar is hidden when in-app purchase dialog gets displayed and it looks to me like it's a BottomSheetDialog.

How can I not show the StatusBar when I'm displaying a BottomSheetDialog?

HB.
  • 4,116
  • 4
  • 29
  • 53
  • Hi.. I just tried and it works just fine for me. Let me post what I have tried.. – sanjeev Nov 19 '19 at 08:44
  • @sanjeev Ok thanks, I'm waiting for your response. – HB. Nov 19 '19 at 08:49
  • Right solution: https://stackoverflow.com/questions/33644326/hiding-status-bar-while-showing-alert-dialog-android#answer-40744282 – ATES May 20 '21 at 22:15

3 Answers3

1

I have applied theme to my BottomSheetDialog and it works perfectly for me.

This is my v21/styles.xml:

P.S: I have used this for windowContentTransitions in my theme hence not necessary to use.

<style name="AppTheme.RoundedBottomDialog">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
        <item name="android:windowFullscreen">true</item>
        <item name="android:popupMenuStyle">@style/PopupMenu</item>
        <item name="bottomSheetDialogTheme">@style/AppBottomSheetDialogTheme</item>
    </style>
    <style name="AppBottomSheetDialogTheme"
        parent="Theme.Design.Light.BottomSheetDialog">
        <item name="bottomSheetStyle">@style/AppModalStyle</item>
    </style>

    <style name="AppModalStyle"
        parent="Widget.Design.BottomSheet.Modal">
        <item name="android:background">@drawable/white_bottom_sheet</item>
    </style>

This is my styles.xml:

 <style name="AppTheme.RoundedBottomDialog">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
        <item name="android:windowFullscreen">true</item>
        <item name="android:popupMenuStyle">@style/PopupMenu</item>
        <item name="bottomSheetDialogTheme">@style/AppBottomSheetDialogTheme</item>
    </style>
    <style name="AppBottomSheetDialogTheme"
        parent="Theme.Design.Light.BottomSheetDialog">
        <item name="bottomSheetStyle">@style/AppModalStyle</item>
    </style>

    <style name="AppModalStyle"
        parent="Widget.Design.BottomSheet.Modal">
        <item name="android:background">@drawable/white_bottom_sheet</item>
    </style>

And I have applied it to <activity> like,

<activity
            android:name=".SomeActivity"
            android:configChanges="locale|orientation|keyboardHidden"
            android:screenOrientation="portrait"
            android:theme="@style/AppTheme.RoundedBottomDialog"
            android:windowSoftInputMode="adjustResize|stateAlwaysHidden" />
sanjeev
  • 1,664
  • 19
  • 35
1

Might be late to answer this question. For others reference, the StatusBar will not be shown when the following flags are set before the return of the onCreateView method:

dialog?.window?.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
        WindowManager.LayoutParams.FLAG_FULLSCREEN)

This is applied to when showing a modal bottom sheet dialog with BottomSheetDialogFragment. Tested on a device running on Android 8.0.

For persistent bottom sheets with BottomSheetBehavior, just apply a fullscreen theme to the Activity or set the android:windowFullscreen attribute to true on the Activity's theme will do.

CodePlay
  • 1,914
  • 14
  • 20
0

I solve this by call hideStatusBar after dialog show() method. I use kotlin style.

    fun hideStatusBar() {
    val uiOptions = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
            View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY or
            View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or
            View.SYSTEM_UI_FLAG_FULLSCREEN
    window?.decorView?.systemUiVisibility = uiOptions
}
Snow Albert
  • 547
  • 7
  • 15