📜  测量视图高度android - 无论代码示例

📅  最后修改于: 2022-03-11 14:56:29.958000             🧑  作者: Mango

代码示例1
ViewTreeObserver vto = frameAbout.getViewTreeObserver();
vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {

int width = frameAbout.getMeasuredWidth();
int height = frameAbout.getMeasuredHeight();
ViewGroup.LayoutParams params = fakeheight.getLayoutParams();
params.height = height - 200;
fakeheight.setLayoutParams(params);
}
});