【发布时间】:2014-04-10 02:15:20
【问题描述】:
我只是想知道是否有可能在一个布局 xml 文件中,也许顶部的垂直线性布局有一个水平线性布局,然后在其下方(垂直布局内部)有一个列表视图,占据屏幕的其余部分?
我找不到任何具体的信息,我想在尝试之前知道它是否可能,谢谢!
【问题讨论】:
我只是想知道是否有可能在一个布局 xml 文件中,也许顶部的垂直线性布局有一个水平线性布局,然后在其下方(垂直布局内部)有一个列表视图,占据屏幕的其余部分?
我找不到任何具体的信息,我想在尝试之前知道它是否可能,谢谢!
【问题讨论】:
给 ListView layout_height="0dp" 和 layout_weight="1"。它将占用未使用的剩余空间购买兄弟LinearLayout。
<LinearLayout
android:layout_width:match_parent
android:layout_height:match_parent
android:orientation:vertical >
<LinearLayout
android:layout_width:match_parent
android:layout_height:wrap_content
android:orientation:norizontal >
<!-- other views --->
</LinearLayout>
<ListView
android:layout_width:match_parent
android:layout_height:0dp
android:layout_weight:1 />
</LinearLayout>
【讨论】: