LinearLayout没有为动态内容调整大小

时间:2015-03-18 03:09:07

标签: android android-layout

我能够以编程方式将TextViews添加到LinearLayout,但是文本会在其下方的TextView上进行写入。我不确定如何扩展我的LinearLayout以包含新内容?这是我的XML的相关部分,它位于RelativeLayout

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/item_header"
    android:id="@+id/item_features"
    android:orientation="horizontal"
    />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/item_description_header"
    android:layout_below="@id/item_features"
    android:text="Item Description" />

我的代码如下。 mFeatureArea是LinearLayout:

for (String item: spot.getFeatures()){
    TextView feature = new TextView(this);
    feature.setText(item);
    mFeatureArea.addView(feature);
}

但是,我得到的是在项目描述标题之上分层的功能。在一些谷歌搜索后,我尝试在LinearLayout和主要RelativeLayout上调用.requestLayout,但是这没有解决问题?

1 个答案:

答案 0 :(得分:0)

mFeaturArea-LineraLayout的父组件是什么?

看起来它是FramewLayout或RelativeLayout都将重叠。检查相应的父组件属性并正确设置参数以调整对齐。

相关问题