0

I made alertDialog using Builder and asigned layout to it like this:

View view2 = LayoutInflater.from(getContext()).inflate(R.layout.information_dialog_layout, null);
    AlertDialog alertDialog = new AlertDialog.Builder(getContext(), R.style.ert).create();
    alertDialog.setView(view2);
    alertDialog.show();

but can not retrive dialogs height in px, tryed 'Rect' class as well but didn't help (may be setting that one wrong though)...? P.S I've looked up some of the answer to similar problem here on StackOverflow but none of those work for me:s

pb4now
  • 1,305
  • 4
  • 18
  • 45

1 Answers1

0

You maybe tempted to use

view2.getHeight();

but the result would be inaccurate.

but

alertDialog.getWindow().getDecorView().getHeight();

is a better alternative as it would return the actual height of the dialogue including the Title and Buttons. Just make sure the Dialogue has focus when you call the above code.

More Info

Community
  • 1
  • 1
Sakchham
  • 1,689
  • 12
  • 22
  • it returns "0" as well:s -when U say "has focus" U mean to put that "after alerDialog.show() ?- or am I missunderstanding? – pb4now Jul 04 '16 at 20:27