PopupWindow获取不到高度

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/nidongde521/article/details/77897645

开发时,PopupWindow获取不到高度

主要问题是在第一次初始化PopupWindow对象时,并没有计算出来高度,但是第二次之后就可以获取到了。
经过测试,以下的方式可以完美解决这个问题:

//优先进行计算
popupWindow.getContentView().measure(0, 0);
//之后通过此方法回去就可以了
popupWindow.getContentView().getMeasuredHeight();

如果你的不起作用,请留言

猜你喜欢

转载自blog.csdn.net/nidongde521/article/details/77897645