Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: How to have dialogFragment to fullscreen

Hello I have tried to override the theme to the dialogFragment for fullscreen but the full screen I wanted was an overlay on top of the previous activity so when the dialogFragment is opened, we still can see back activity from the padding between the screen and the dialogFragment.

This is the style I have used for full screen

<style name="fullscreen_dialog" parent="android:Theme" >
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowFullscreen">true</item>
    <item name="android:windowIsFloating">false</item>
</style>
like image 945
LittleFunny Avatar asked Oct 14 '15 00:10

LittleFunny


People also ask

Is DialogFragment deprecated?

This method is deprecated. androidx.

How do you show DialogFragment?

Showing the DialogFragment It is not necessary to manually create a FragmentTransaction to display your DialogFragment . Instead, use the show() method to display your dialog. You can pass a reference to a FragmentManager and a String to use as a FragmentTransaction tag.

What is the difference between dialog & DialogFragment?

Dialog: A dialog is a small window that prompts the user to make a decision or enter additional information. DialogFragment: A DialogFragment is a special fragment subclass that is designed for creating and hosting dialogs.

How do I destroy DialogFragment?

tl;dr: The correct way to close a DialogFragment is to use dismiss() directly on the DialogFragment. Control of the dialog (deciding when to show, hide, dismiss it) should be done through the API here, not with direct calls on the dialog. Dismiss the fragment and its dialog.


1 Answers

This is the solution I figured out to handle your issue:

@Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        Dialog dialog = super.onCreateDialog(savedInstanceState);    
        dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
        return dialog;
    }

    @Override
    public void onStart() {
        super.onStart();
        Dialog dialog = getDialog();
        if (dialog != null) {
           dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
            dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        }
    }
like image 181
droidev Avatar answered Sep 21 '22 20:09

droidev