view.findViewById(R.id.doc_prof_det_add_speciality_btn).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                AlertDialog.Builder alertDialog = new AlertDialog.Builder(v.getContext());
                LayoutInflater factory = LayoutInflater.from(v.getContext());
                final View view = factory.inflate(R.layout.doc_prof_det_add_speciality, null);
                alertDialog.setView(view);
            alertDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
            alertDialog.setPositiveButton("Save", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                }
            });
            alertDialog.show();
        }
    });
            Asked
            
        
        
            Active
            
        
            Viewed 41 times
        
    0
            
            
        - 
                    please use proper code formatting. – karan Jul 04 '16 at 06:11
- 
                    Possible duplicate of [How to set dialog to show with full screen?](http://stackoverflow.com/questions/6329360/how-to-set-dialog-to-show-with-full-screen) – Janki Gadhiya Jul 04 '16 at 07:12
1 Answers
1
            
            
        Try this:
alertDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
            alertDialog.setPositiveButton("Save", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                }
            });
            alertDialog.show();
           //Grab the window of the dialog, and change the width
           WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
           Window window = alertDialog.getWindow();
           lp.copyFrom(window.getAttributes());
           //This makes the dialog take up the full width
           lp.width = WindowManager.LayoutParams.MATCH_PARENT;
           lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
           window.setAttributes(lp);
    }
}); 
 
    
    
        Gulmuhammad Akbari
        
- 1,986
- 2
- 13
- 28
- 
                    hello i add below code but it will give Error:(60, 44) error: cannot find symbol method getWindow() – Jack D Jul 04 '16 at 06:28
- 
                    Check this out: http://www.techrepublic.com/article/pro-tip-unravel-the-mystery-of-androids-full-screen-dialog-fragments/ – Gulmuhammad Akbari Jul 04 '16 at 06:53
 
    