Android makes full screen Dialog mode with status bar showing

I want to make the dialog box full screen, but not hide the status bar.

If the usage style is Theme_Light_NoTitleBar_Fullscreen , the dialog box is full screen.

If the Theme_Material_Light_NoActionBar_TranslucentDecor style is Theme_Material_Light_NoActionBar_TranslucentDecor , it works, but the top of the dialog box becomes transparent. I can do this better by querying the height of the status bar and add a top complement to my dialog layout. This solution works fine, except that it does not work if I connected an animation to it.

I am very confused why Google makes this dialog box so difficult to use, and if I am doing the full-screen dialog correctly here?

+7
source share
4 answers

Just use THEME_BLACK_NoTitleBar Worked for me!

+9
source

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); 
+4
source

I found a snipplet from the blog, after several attempts I found that I needed to use Theme_Black_NoTitleBar_Fullscreen in the constructor along with snipplet during onCreate . now my dialog is fullscreen and shows the 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 snipplet

+2
source

Use android.R.style.Theme_Black_NoTitleBar

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

Screen example

+1
source

Source: https://habr.com/ru/post/1242672/


All Articles