Calvin Kung
Calvin Kung

Reputation: 133

Android make Dialog fullscreen with status bar showing

I want to make a dialog box with full screen but not hiding the status bar.

If use style Theme_Light_NoTitleBar_Fullscreen, the dialog box occupies the whole screen.

If use style Theme_Material_Light_NoActionBar_TranslucentDecor, it seems working but the top of the dialog box actually is becoming transparent. I can make it better by enquiring the status bar height and add top padding to my dialog layout. This solution seems works fine, except it does not work if I attached an animation to it.

I am very confused why Google make the dialog box so complicated to use, and if I am doing correctly to make a full screen dialog box here?

Upvotes: 11

Views: 20753

Answers (7)

Ragesh Valeroso
Ragesh Valeroso

Reputation: 11

Just use your own application theme style. It will come along. example: Dialog dialog = new Dialog(context, R.style.YOUR_THEME_STYLE); themes/style

Upvotes: 0

ucMax
ucMax

Reputation: 5438

It maybe too late but for the sake of others who have the same problem :

    dialog = new dialog(context,android.R.style.Theme_Translucent_NoTitleBar);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT,
                                 WindowManager.LayoutParams.MATCH_PARENT);

Upvotes: 6

Mudit Goel
Mudit Goel

Reputation: 354

Simply use :

Dialog dialog = new Dialog(ctx, android.R.style.Theme_Black_NoTitleBar);

This will display the status bar and remaining dialog will be full screen

Upvotes: 0

Anubhav
Anubhav

Reputation: 2180

You can use

android.R.style.Theme_Black_NoTitleBar_Fullscreen

AlertDialog.Builder builder = new AlertDialog.Builder(Objects.requireNonNull(getActivity()),
            android.R.style.Theme_Black_NoTitleBar_Fullscreen);

This will use the primaryDarkColor for the status bar.

Upvotes: 2

Tuan Nguyen
Tuan Nguyen

Reputation: 269

Use android.R.style.Theme_Black_NoTitleBar

AlertDialog.Builder builder = new AlertDialog.Builder(context,
                   android.R.style.Theme_Black_NoTitleBar);

Example screen

Upvotes: 3

Satish Silveri
Satish Silveri

Reputation: 393

Just use THEME_BLACK_NoTitleBar Worked For me!!!

Upvotes: 13

Yamgemy
Yamgemy

Reputation: 29

I have found a snipplet from a blog, after a few tries i found that i have to use Theme_Black_NoTitleBar_Fullscreen in constructor, together with the snipplet during onCreate. now my dialog is fullscreen and shows status bar.

public YourCustomDiag(Activity act){
    //step 1, required. to stretch the dialog to full screen
    super(act, android.R.style.Theme_Black_NoTitleBar_Fullscreen);
}

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.custom_dialog_layout);
    KeepStatusBar();
}

//step 2, required
private void KeepStatusBar(){    
    WindowManager.LayoutParams attrs = getWindow().getAttributes();
    attrs.flags &= ~WindowManager.LayoutParams.FLAG_FULLSCREEN;
    getWindow().setAttributes(attrs);
}

this is the source where i found the snipplet

Upvotes: 2

Related Questions