1

I am tryting to customize a alert dialog in android but the problem is i want to make dialog over the side of the screen too , that i means i want my dialog to be fit horizontally without any extra gap. So far i have written following code inside onDialog overridden method of Activity. but i am still getting gaps on both the side. I want dialog with Relative to the layout

enter image description here

            LayoutInflater factory = LayoutInflater.from(this);
            final View EntryView = factory.inflate(R.layout.mc_custom_dlg, null);

            final AlertDialog.Builder alertDialog =  new AlertDialog.Builder(this);

            alertDialog.setCancelable(true);
            alertDialog.setView(EntryView);
            alertDialog.setInverseBackgroundForced(true);
            Dialog directionDlg = alertDialog.create();
            directionDlg.requestWindowFeature(Window.FEATURE_NO_TITLE);

             WindowManager.LayoutParams wndParams = directionDlg.getWindow().getAttributes();            
             wndParams.flags=LayoutParams.FLAG_LAYOUT_NO_LIMITS | LayoutParams.FLAG_NOT_TOUCH_MODAL;
             wndParams.x=0;
             wndParams.y=-70;
             wndParams.gravity=-1; 
             wndParams.dimAmount=0;


             directionDlg.getWindow().setLayout(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
Hunt
  • 8,215
  • 28
  • 116
  • 256
  • see http://stackoverflow.com/questions/4406804/how-to-control-the-width-and-height-of-default-alert-dialog-in-android – Sunil Kumar Sahoo Jun 17 '11 at 11:08
  • Which parameter do i need to specify to make the width fitted and relative so that if the phone screen size changes it reacts accordingly – Hunt Jun 17 '11 at 11:51
  • Try to change `margin` and/or `padding` to `0` – jamapag Jun 17 '11 at 12:12
  • if i set 0dip my application crashes – Hunt Jun 17 '11 at 12:28
  • i tride to replace its default background by replace following tag @drawable/bg_dlg but i am really afraid that if a screen size changes for larger phone then things will go bad :( so does any one has any solution – Hunt Jun 17 '11 at 13:28

0 Answers0