Full Screen DialogFragment in Android

android-dialogfragment full width
android full screen transparent dialog
android-dialogfragment width percentage
android-dialogfragment margin
full screen fragment android
android dialogfragment remove padding
android-dialogfragment too small
full screen custom dialog android

I'm trying to show an almost fullscreen DialogFragment. But I'm somehow not able to do so.

The way I am showing the Fragment is straight from the android developer documentation

FragmentManager f = ((Activity)getContext()).getFragmentManager();
FragmentTransaction ft = f.beginTransaction();
Fragment prev = f.findFragmentByTag("dialog");
if (prev != null) {

// Create and show the dialog.
DialogFragment newFragment = new DetailsDialogFragment();
newFragment.show(ft, "dialog");

I know naively tried to set the RelativeLayout in the fragment to fill_parent and some minWidth and minHeight.


I would know expect the DialogFragment to fill the majority of the screen. But I only seems to resize vertically but only until some fixed width horizontally.

I also tried to set the Window Attributes in code, as suggested here: http://groups.google.com/group/android-developers/browse_thread/thread/f0bb813f643604ec. But this didn't help either.

I am probably misunderstanding something about how Android handles Dialogs, as I am brand new to it. How can I do something like this? Are there any alternative ways to reach my goal?

Android Device: Asus EeePad Transformer Android 3.0.1

Update: I now managed to get it into full screen, with the following code in the fragment

public void onCreate(Bundle savedInstanceState) {
    setStyle(STYLE_NO_FRAME, android.R.style.Theme_Holo_Light);

Unfortunately, this is not quite want I want. I definitely need a small "padding" around the dialog to show the background.

Any ideas how to accomplish that?

Try switching to a LinearLayout instead of RelativeLayout. I was targeting the 3.0 Honeycomb api when testing.

public class FragmentDialog extends Activity {

protected void onCreate(Bundle savedInstanceState) {

    Button button = (Button) findViewById(R.id.show);
    button.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {

public void onSaveInstanceState(Bundle outState) {

void showDialog() {
    FragmentTransaction ft = getFragmentManager().beginTransaction();
    DialogFragment newFragment = MyDialogFragment.newInstance();
    newFragment.show(ft, "dialog");

public static class MyDialogFragment extends DialogFragment {

    static MyDialogFragment newInstance() {
        MyDialogFragment f = new MyDialogFragment();
        return f;

    public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.fragment_dialog, container, false);
        return v;


and the layouts: fragment_dialog.xml

<?xml version="1.0" encoding="utf-8"?>


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    <Button android:id="@+id/show"

Android: How to have dialogFragment to fullscreen, You could just manually set the layout params in code like so. Hope it helps ! :). Also check it this SO Adjusting size of custom dialog box in  Android full screen dialogs using DialogFragment Dialogs have always been an intuitive way of displaying quick details without having to take users to a different screen. Full-Screen dialogs give a variety of use cases for performing quick UI screens along with the power of fragments without having to fire up a separate activity.

To get DialogFragment on full screen

Override onStart of your DialogFragment like this:

public void onStart()
    Dialog dialog = getDialog();
    if (dialog != null)
        int width = ViewGroup.LayoutParams.MATCH_PARENT;
        int height = ViewGroup.LayoutParams.MATCH_PARENT;
        dialog.getWindow().setLayout(width, height);

And thanks very much to this post: The-mystery-of-androids-full-screen-dialog-fragments

Full Screen Dialog Fragment in Android, In this post, we'll learn full screen dialog fragments in Android. For that will create an example app that app contains full screen dialog fragment  In this post, we’ll learn about full screen dialog fragment Android. For better understanding, I will create a sample app that app contains full screen dialog in Android. Additionally, we’ll learn how to pass data dialog to fragment or also. So let’s get started. Full Screen Dialog Fragment (Demo App)

public void onCreate(Bundle savedInstanceState) {


Fullscreen Activity in Android?, How do I change the size of my dialog box in Android? As far as the Android API got updated, the suggested method to show a full screen dialog is the following: FragmentTransaction transaction = this.mFragmentManager.beginTransaction(); // For a little polish, specify a transition animation transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); //

According to this link DialogFragment fullscreen shows padding on sides this will work like a charm.

public Dialog onCreateDialog(final Bundle savedInstanceState) {

    // the content
    final RelativeLayout root = new RelativeLayout(getActivity());
    root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

    // creating the fullscreen dialog
    final Dialog dialog = new Dialog(getActivity());
    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

    return dialog;

How to control the width and height of the default Alert Dialog in , Creating the custom dialog layout. Let's begin by creating a simple layout to view in the fullscreen dialog (A dialog layout that takes full width and  Why not use a Fragment instead of DialogFragment. With Fragment, you would need to prepare a fullscreen layout and load/replace the Fragment into the layout. With DialogFragment, there is no need of such layout. The following code and layout will create a layout with black overlay which filled 90% of the screen.

Make a Full screen DialogFragment by using only the style
First solution

1. Add to your style.xml:

    <style name="FullScreenDialog" parent="Theme.AppCompat.Light.Dialog">
        <item name="android:backgroundDimEnabled">false</item>
        <item name="android:windowNoTitle">true</item>
        <item name="android:padding">0dp</item>
        <item name="android:windowIsFloating">false</item>
        <item name="android:windowBackground">@android:color/transparent</item>

2. Add to your DialogFragment:

public int getTheme() {
    return R.style.FullScreenDialog;
Alternative solution
override fun onCreate(savedInstanceState: Bundle?) {

    setStyle(DialogFragment.STYLE_NO_FRAME, R.style.AppTheme)

where AppTheme is the theme you defined in styles.

Android full screen dialogs using DialogFragment, show you how to create a fullscreen dialog using a dialogfragment in android. Codes: https Duration: 16:09 Posted: Oct 21, 2018 I am making full screen dialog with dialog fragment. I am successfully shown dialog but problem is in its width and height. It cannot shows full screen size. I want to set width and height with accumulating full screen size like an Activity. Kindly guide me how to set dialog width and height to accumulate it to full screen size

Android Tutorial, In this post, we'll learn about full-screen dialog fragment Android Full Source - https Duration: 0:42 Posted: Dec 3, 2019 sorry I mean almost full screen or full image – user790156 Jun 13 '11 at 10:49 3 In conjunction with answer to willytate if you have to dialog then use android.R.style.Theme_Translucent_NoTitleBar_Fullscreen in theme – ingsaurabh Jun 13 '11 at 10:50

Full Screen Dialog Fragment in Android, Pro tip: Unravel the mystery of Android's full screen dialog fragments file contains the definition for both the activity and the dialog fragment. A common issue for developers new to dialog fragments is how to display a dialog full screen. Since dialog fragments must return a view in the create view override, it would seem that assigning a

Pro tip: Unravel the mystery of Android's full screen dialog fragments , We can use DialogFragment to show a fullscreen overlay (like loading an Activity, but with Fragment). Why not use a Fragment instead of  Android DialogFragments DialogFragment is a utility class which extends the Fragment class. It is a part of the v4 support library and is used to display an overlay modal window within an activity that floats on top of the rest of the content. Essentially a DialogFragment displays a Dialog but inside a Fragment.

  • good read: techrepublic.com/article/…
  • You save my time, tysm
  • And for me, I needed to use a RelativeLayout, but the dialog width wasn't adjusting properly to the contents, so I nested the RelativeLayout in a LinearLayout whose only child was the RelativeLayout... this triggered the proper width adjustments.
  • I tested everything, but I can confirm the only thing that worked for my DialogFragment was wrapping my whole layout in a LinearLayout. That way I could set width and height of my (now wrapped) original layout...wasted hours on this
  • Setting minWidth and minHeight to be somehing large seems to be the crucial part; but this is a hack instead of a clean solution. The answer given by @David below - explained further in the link he gives - also works and is clean.
  • @tir38 I don't think that's true because onCreateDialog() already has an implementation in the superclass.
  • This should be the accepted answer. Elaborate and clear
  • Exactly this works, but i tried with Videoview and it doesnt works for that. StatusBar still shows. So this fixed me below code: dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
  • finally sort out, thansk for suggestion @David
  • This worked nicely for me. I used ViewGroup.LayoutParams.WRAP_CONTENT for the height. Thanks.
  • this is clean and non-hacky
  • this is not working for my case.. it showing some padding from all corners. any help?