How to make DialogFragment width to Fill_Parent

前端 未结 18 2482
栀梦
栀梦 2020-12-04 08:21

I am working on an android application where I am using DialogFragment to display the dialog but its width is very small. How I can make this width to fil

18条回答
  •  情歌与酒
    2020-12-04 09:05

    This is worked for me

    Create your custom style :

       
    

    You can also try use the right parent to match your other dialogs. for example parent="ThemeOverlay.AppCompat.Dialog" and so on.

    Use this style in your dialog

    public class MessageDialog extends DialogFragment {
    
    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setStyle(DialogFragment.STYLE_NO_TITLE, R.style.DialogStyle);
    }
    
    // your code 
    }
    

提交回复
热议问题