I have a custom class which extends AlertDialog. I would like to create a dialog with which I can control the width, height, x, and y positions programmatically. Here is what I currently have:
MyDialog md = new MyDialog(context, AlertDialog.THEME_HOLO_LIGHT);
//md.setMessage("");
md.show();
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
lp.copyFrom(md.getWindow().getAttributes());
lp.x = 100;
lp.y = 400;
lp.width = 200;
lp.height = 400;
md.getWindow().setAttributes(lp);
If I remove the setMessage line, no dialog is displayed. If I leave it in though it will show a blank dialog that acts strangely:
The height of the dialog seems locked in to the height of a single line of text rather than using the height value that is set.
The dialog APPEARS to be one line tall, however, it does not allow it to go any lower on the screen than the set height would allow. A dialog positions itself on screen to ensure that all of it is always visible, which is why this occurs.
Also, if I add a lot of text to the setMessage method the dialog will stretch to contain all of it, is there a way to set it so that it crops whatever does not fit?
In summary: It appears that alert dialog does quite a bit behind the scenes in terms of formatting that I would like to disable. Is there a better way to format a dialog? The solution to this problem MUST use Dialog as a base class. Thanks in advance.