How to set dialog to show in full screen?

AndroidAndroid Fullscreen

Android Problem Overview


I have a GridView and i want to make an implémentation of a dialog, on which the picture that i have selected should display in full screen.

so how can i make the dialog shows in a full screen mode ? thanks!

Android Solutions


Solution 1 - Android

try

Dialog dialog=new Dialog(this,android.R.style.Theme_Black_NoTitleBar_Fullscreen)

Solution 2 - Android

based on this link , the correct answer (which i've tested myself) is:

put this code in the constructor or the onCreate() method of the dialog:

getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT,
				WindowManager.LayoutParams.MATCH_PARENT);

in addition , set the style of the dialog to :

<style name="full_screen_dialog">
	<item name="android:windowFrame">@null</item>
	<item name="android:windowIsFloating">true</item>
	<item name="android:windowContentOverlay">@null</item>
	<item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
	<item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item>
</style>

this could be achieved via the constructor , for example :

public FullScreenDialog(Context context)
{
  super(context, R.style.full_screen_dialog);
  ...

EDIT: an alternative to all of the above would be to set the style to android.R.style.ThemeOverlay and that's it.

EDIT2: To support material library, add Gradle dependency to app(module) build.gradle file

implementation "com.google.android.material:material:$material_version"

Then set dialog's theme to R.style.ThemeOverlay_MaterialComponents

Solution 3 - Android

The easiest way I found

Dialog dialog=new Dialog(this,android.R.style.Theme_Black_NoTitleBar_Fullscreen);
        dialog.setContentView(R.layout.frame_help);
        dialog.show();

Solution 4 - Android

EDIT Until such time as StackOverflow allows us to version our answers, this is an answer that works for Android 3 and below. Please don't downvote it because it's not working for you now, because it definitely works with older Android versions.


You should only need to add one line to your onCreateDialog() method:

@Override
protected Dialog onCreateDialog(int id) {
	//all other dialog stuff (which dialog to display)

	//this line is what you need:
	dialog.getWindow().setFlags(LayoutParams.FLAG_FULLSCREEN, LayoutParams.FLAG_FULLSCREEN);

	return dialog;
}

Solution 5 - Android

dialog = new Dialog(getActivity(),android.R.style.Theme_Translucent_NoTitleBar);
	dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
	dialog.setContentView(R.layout.loading_screen);
	Window window = dialog.getWindow();
	WindowManager.LayoutParams wlp = window.getAttributes();

	wlp.gravity = Gravity.CENTER;
	wlp.flags &= ~WindowManager.LayoutParams.FLAG_BLUR_BEHIND;
	window.setAttributes(wlp);
	dialog.getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
	dialog.show();

try this.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser790156View Question on Stackoverflow
Solution 1 - AndroidAhmed SalemView Answer on Stackoverflow
Solution 2 - Androidandroid developerView Answer on Stackoverflow
Solution 3 - AndroidJavier RobertoView Answer on Stackoverflow
Solution 4 - AndroidCaspar HarmerView Answer on Stackoverflow
Solution 5 - AndroidPrateek SharmaView Answer on Stackoverflow