How to set dialog to show in full screen? [closed]
Solution 1:
try
Dialog dialog=new Dialog(this,android.R.style.Theme_Black_NoTitleBar_Fullscreen)
Solution 2:
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:
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:
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;
}