【发布时间】:2023-03-15 23:14:01
【问题描述】:
如果父级是 PopupWindow 而不是 ViewGroup,我如何计算膨胀视图的宽度和高度?我不能使用LayoutInflator.inflate(int resId, ViewGroup parent, attachToRoot boolean),因为 PopupWindow 不是 ViewGroup,所以我改用LayoutInflator.inflate(int resId),但之后我 getWidth() 和 getHeight() 返回零:(
我需要调整 PopupWindow 的大小以适应视图,但在视图有父视图之前不能这样做。我有先有鸡还是先有蛋的问题吗?
顺便说一句,View 是 RelativeView 的子类,因此手动计算它基本上是不可能的。
提前致谢, 巴里
【问题讨论】:
-
调用
LayoutInflator.inflate(int resId, ViewGroup parent, attachToRoot boolean)后你能得到你的View的尺寸吗?
标签: android