How to get dialog size?

前端 未结 4 655
情书的邮戳
情书的邮戳 2020-12-20 12:58

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().

4条回答
  •  我在风中等你
    2020-12-20 13:31

    @Kormilsev Anatoliy has answered correct and I am just improving. So in the class you inherit from Dialog class just override the method:

    @Override
    public void onWindowFocusChanged (boolean hasFocus) {
        super.onWindowFocusChanged(hasFocus);
        height = getWindow().getDecorView().getHeight();
    }
    

提交回复
热议问题