In my program I create a dialog with the code below. Ideally I would like to scale the dialog by entering width and height parameter programmatically. Can anyone show me how to do this?
dialog = new Dialog(MainActivity.this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
popUpLayout = Globals.layoutInflater.inflate(R.layout.pop_up_layout, null);
dialog.setContentView(popUpLayout);
dialog.show();
According to Android platform developer Dianne Hackborn in this discussion group post, Dialogs set their Window's top level layout width and height to WRAP_CONTENT . To make the Dialog bigger, you can set those parameters to MATCH_PARENT . Demo code: AlertDialog.
getWindow(). getAttributes(); // change this to your dialog. params. y = -100; // Here is the param to set your dialog position.
Here is the code that ended up working:
dialog.getWindow().setLayout(275, 350);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With