-2

所以我有这个布局场景,我还没有找到任何理想的解决方案。我已经画了它,我希望它可以理解。

在此处输入图像描述

现在我的 ListView 总是在底部的 LinearLayout 之上。当 ListView 的项目很少时,TextView 就在下方,看起来还不错。但是,当它有很多项目时,它会压碎介于 LW 和底部容器之间的 TextView,无论如何,它应该始终存在。

谁能给我一个实现这一点的xml示例?

4

2 回答 2

1

您可以将ListView内部 a包裹起来LinearLayout,并将权重设置为 this Linearlayout、theTextView和 bottom LinearLayout。(您必须将 ListView 包装在 a 中LinearLayout,因为您不能将权重应用于 a ListView)。

于 2012-10-27T00:25:38.037 回答
-1

If I don't missundestand you, You try to create a ListView such as wrap_content? and the TextView is always below the ListView? If i'm not wrong, so, this is what you need:

 <LinearLayout // Your list view and TextView in a same linear layout
    android:layout_alignParentTop="true"
    android:layout_width="fill_parent"
    android:layout_height="400dp" // With this specific height, your TextView will
                                  // always in this range!
    android:orientation="vertical" >

    <ListView
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="0.1" >
    </ListView>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="5dp"
        android:layout_marginBottom="91dp"
        //layout_gravity = "right"?? I'm not sure, you should make it right alignment 
    />
</LinearLayout>

<LinearLayout /> // This is your linear layout at the Bottom, 2 Lineary layout is 
                 // putted in a Relative layout

The layout above give you a ListView at the top, and the TextView is below, the LinearLayout at the Bottom. Try it out!!

于 2012-10-27T02:25:20.530 回答