我在在项目动态调用update方法去实现更新它的宽高,代码如下:
update(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.WRAP_CONTENT);
但是总是不起作用,去查了下update方法,一部分具体如下:
public
void
update(
int
x,
int
y,
int
width,
int
height,
boolean
force) {
if
(width != -
1
) {
mLastWidth = width;
setWidth(width);
}
if
(height != -
1
) {
mLastHeight = height;
setHeight(height);
}
然而LinearLayout.LayoutParams.MATCH_PARENT的值就是-1.
解决办法就是如果想动态更新popupwindow的宽或高为充满,那么可以把LinearLayout.LayoutParams.MATCH_PARENT设为获取屏幕的实际宽高去设置。