我正在尝试在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();
}
答案 0 :(得分:6)
尝试更改覆盖onMeasure方法的值,同样在您的代码中我自己调用measure()或requestLayout()