我正在尝试以LinearLayout
编程方式创建两个宽度相等的:
mGroupLayout.setOrientation(HORIZONTAL);
mGroupLayout.setWeightSum(2f);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
0,
LinearLayout.LayoutParams.WRAP_CONTENT
);
params.weight = 1.0f;
leftLayout = new LinearLayout(getContext());
leftLayout.setOrientation(VERTICAL);
leftLayout.setLayoutParams(params);
mGroupLayout.addView(
leftLayout,
params
);
rightLayout = new LinearLayout(getContext());
rightLayout.setOrientation(VERTICAL);
rightLayout.setLayoutParams(params);
mGroupLayout.addView(
rightLayout,
params
);
但是我所有的线性布局都不可见(它们的宽度为 0)。我怎么能这样做?