Android 如何设置LinearLayout LayoutParams以显示所有高度

Android 如何设置LinearLayout LayoutParams以显示所有高度,android,android-layout,layout,layoutparams,Android,Android Layout,Layout,Layoutparams,基于这个问题,我制定了以下代码: LinearLayout oLl = new LinearLayout(getContext()); TextView oNum = new TextView(getContext()); oNum.setText(String.valueOf(nPos + 1) + ". "); oNum.setTypeface(null, Typeface.BOLD); oNum.setTextColor(Color.RED);

基于这个问题,我制定了以下代码:

    LinearLayout oLl = new LinearLayout(getContext());

    TextView oNum = new TextView(getContext());
    oNum.setText(String.valueOf(nPos + 1) + ". ");
    oNum.setTypeface(null, Typeface.BOLD);
    oNum.setTextColor(Color.RED);
    oNum.setTextSize(18);
    oNum.setPadding(Dp_to_Px(10),Dp_to_Px(15),0,0);

    TextView oText = new TextView(getContext());
    oText.setText(oPreg.getcPregunta());
    oText.setTypeface(null, Typeface.BOLD);
    oText.setTextColor(Color.BLACK);
    oText.setTextSize(18);

    LinearLayout.LayoutParams oLp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.WRAP_CONTENT);

    oLl.addView(oNum);
    oLl.addView(oText,oLp);

    oContainer.addView(oLl,oLp);
但它切断了最后一条线

编辑:

单选按钮的代码:

 RadioGroup oRg = new RadioGroup(getContext());
    oRg.setOrientation(RadioGroup.HORIZONTAL);
    oRg.setPadding(Dp_to_Px(10),Dp_to_Px(6),0,0);

    RadioButton oRbSi = new RadioButton(getContext());
    oRbSi.setText(getContext().getString(R.string.Si));
    oRbSi.setPadding(0,0,Dp_to_Px(25),Dp_to_Px(5));

    RadioButton oRbNo = new RadioButton(getContext());
    oRbNo.setText(getContext().getString(R.string.No));

    oRg.addView(oRbSi);
    oRg.addView(oRbNo);

    oContainer.addView(oRg);
以及oContainer的定义:

<LinearLayout
    android:id="@+id/encuesta_frg_contaier"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

</LinearLayout>
这是因为:oNum.setPaddingDp_到_Px10,Dp_到_Px15,0,0


oNum文本视图的顶部有填充,这将oText文本视图推到组织组的下方。请尝试在oLl上设置填充,您的问题应该会得到解决。

如果我错了,很抱歉,我们不能在xml中将“包裹内容高度”设置为线性布局吗?@没有人知道,但我需要在应用程序的这一点上动态创建控件。