如果popupWindow 的高度设置为 wrap_content 时,popupWindow.getHeight()的值为0或负值,此时若要获取popupWindow的高度,需要用popupWindow.getContentView().getMeasuredHeight()方法,当设置为确定值时,getHeight()可以得到设置的具体值。
PopupWindow高度问题记录
最新推荐文章于 2021-05-25 20:52:32 发布
本文介绍了在使用PopupWindow时如何正确获取其高度的方法。当PopupWindow的高度被设置为wrap_content时,直接调用getHeight()可能会返回0或负值。这时应该使用getContentView().getMeasuredHeight()来获取实际高度。如果设置了具体的高度值,则可以直接通过getHeight()获取。
929

被折叠的 条评论
为什么被折叠?



