frameLayout在xml中高度设置match parent是无效的,必须要在代码中进行动态设置,代码的方式获取高度然后set:
fl_child = view.findViewById(R.id.fl_child);
Resources resources = this.getResources();
int childViewHeight = resources.getDisplayMetrics().heightPixels;
fl_child.getLayoutParams().height = childViewHeight;

本文详细介绍了在使用FrameLayout时遇到的高度设置为match_parent无效的问题,并提供了通过代码动态设置高度的解决方案,确保子视图能够正确填充整个屏幕。
2738





