我正在实例化另一片段内的片段。内部片段的宽度和高度定义为match_parent
。还有他们的父母。片段不能正确填充屏幕
这是main Fragment的代码。内部的CustomFragment是内部片段。它是一个带有日历的常规片段。
public class CalendarFragment extends Fragment {
...
public void onViewCreated(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState){
customFragment = new CustomFragment();
customFragment.setArguments(bundle);
FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
transaction.add(R.id.calendar_container, customFragment);
transaction.commit();
...
}
当这个fargment生效时,包含日历的内部片段根据每个日历单元的内容来调整其高度。 截图。注意空白区域:
如果两个片段在其布局中都有match_parent,为什么会出现这种情况?
如果你设置了'android:fitsSystemWindows =“true”'',那么在你的'Activity'中删除它。 – Ironman
@Ironman我没有清单中的这个参数。目前,我的解决方案是根据父代片段高度和行数设置每个单元的最小高度 – learner