小编mat*_*kiv的帖子

无法使用setLayoutParams更改视图的宽度/高度

我想在RelativeLayout中制作方形子(我扩展).在活动开始它工作正常,但加载广告时,我的相对布局变小,但我的代码不影响孩子.扩展RelativeLayout的代码:

protected void onSizeChanged(int w, int h, int oldw, int oldh) {
    int minSize = Math.min(w, h);
    RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) imageViewContainer.getLayoutParams();
    layoutParams.width = minSize;
    layoutParams.height = minSize;
    imageViewContainer.setLayoutParams(layoutParams);
    invalidate();
}
Run Code Online (Sandbox Code Playgroud)

android

1
推荐指数
1
解决办法
1440
查看次数

标签 统计

android ×1