She*_*lam 1 java xml eclipse android android-linearlayout
我有一个带有两个ListView的垂直线性布局.我希望顶级ListView占据屏幕的50%.我希望底部的listivew占据屏幕的50%.我怎么能用XML做到这一点?
Jos*_*arl 11
以下布局应该有效
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<ListView
android:id="@+id/list1"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
/>
<ListView
android:id="@+id/list2"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
这是如何工作的:
wrap_content)在所有视图之间划分,没有高度和layout_weight(layout_weight of View) / (Sum of layout_weights in parent ViewGroup)(Sum of layout_weights in parent ViewGroup) = 2与(layout_weight of View) = 1每个ListView,因此每个ListView占用1/2的可用空间| 归档时间: |
|
| 查看次数: |
3563 次 |
| 最近记录: |