-1

I saw some post on stackoverflow to change the height and width of the dialog box but when i implemented that in my code the dialog box doesn't respond to it. Here I'm attaching some snippet that i'm using for my dialog box.

Can you guys help me out to sort it out please !!!

Code Used

LayoutInflater li = LayoutInflater.from(Inv.this);
            View promptsView = li.inflate(R.layout.importdata, null);

            AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
                    InventoryCount.this);

            alertDialogBuilder.setView(promptsView);            



            // Listener1 of promptsView 
            // Listener2 of promptsView 
            // Listener3 of promptsView 





            AlertDialog alertDialog = alertDialogBuilder.create();
            alertDialogBuilder.setTitle("Any Thing");
            alertDialog.getWindow().setLayout(300, 900);            
            alertDialog.show();
Pranesh Sahu
  • 595
  • 5
  • 26
  • I got my solution over here. http://stackoverflow.com/questions/14907104/alertdialog-with-custom-view-resize-to-wrap-the-views-content Thanks to stackoverflow. – Pranesh Sahu Sep 01 '15 at 16:52

3 Answers3

1

You can change the layout dimensions directly setting the width and height params in your xml file layout/importdata.xml

Or change it programatically this way:

View view_instance = (View)findViewById(R.layout.importdata);
LayoutParams params = view_instance.getLayoutParams();
params.width = your_new_width;
params.height = your_new_height;
view_instance.setLayoutParams(params);
Benjamin Fell
  • 393
  • 2
  • 11
0
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
            this);

    alertDialogBuilder
            .setMessage("Mwssage")
            .setNeutralButton("Ok", null).show().getWindow().setLayout(300,900);

Or you can set wight and height with Builder, but after "show" method.

0
DisplayMetrics displaymetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
alertDialogBuilder
.setMessage("Message")
.setNeutralButton("ok",null)
.show().getWindow().
setLayout(displaymetrics.widthPixels / 3, displaymetrics.heightPixels / 2);