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!
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!
try
Dialog dialog=new Dialog(this,android.R.style.Theme_Black_NoTitleBar_Fullscreen)
Call requires API level 11
–
Tysontyumen DialogFragment
) I see the status bar color is killed by the dialog, the whole screen is the dialog's background color. Does anyone know of a workaround? I tried setting the statusBarColor of the dialog's window, to no effect. P.S.: navigation bar color gets killed too. –
Promoter dialog = Dialog(context!!, android.R.style.Theme_Black_NoTitleBar_Fullscreen)
–
Decode 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
android.R.style.ThemeOverlay
is the key. –
Nate ThemeOverlay.MaterialComponents
is also suitable. Can you please check? –
Discourtesy getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(any bg color));
will "expand" the dialog's width to fullscreen which no need to set theme android.R.style.ThemeOverlay
. Notice that for "width" only. –
Nate ThemeOverlay.MaterialComponents
was enough. Thanks. –
Ribbonwood 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();
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;
}
FLAG_FULLSCREEN cannot be resolved or is not a field
–
Tysontyumen DialogFragment
s onCreateDialog
method. This way, everything is cool. ;-) –
Avaavadavat 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.
© 2022 - 2024 — McMap. All rights reserved.
Dialog
, why not just use the defaultACTION_VIEW
Intent
for image files? – Diagnostician