How to get dialog size?

slezadav picture slezadav · Nov 22, 2012 · Viewed 15.7k times · Source

I am looking for a way to get size of a custom dialog. I went through this question, but the only answer given is pretty useless, because if I try mDialog.getWindow().getAttributes().height; it only returns -2, which is a constant for WRAP_CONTENT attribute which I set to dialog. How can I get the size of it. I want to know the siye for the background image.

Answer

Korniltsev Anatoly picture Korniltsev Anatoly · Nov 22, 2012

Give it a try:

mDialog.getWindow().getDecorView().getHeight()