Tôi muốn tạo bố cục, với một LinearLayout nằm ngang ở trên và dưới, một ListView điền vào giữa.Bố cục vấn đề: cách đặt thứ gì đó ở trên và dưới?
Làm cách nào để xác định tệp main.xml.
Tôi đã cố gắng tạo bố cục với LinearLayout nằm ngang ở trên cùng, TextView ở phía dưới, một ListView điền ở giữa; được rồi. Nhưng sau khi tôi sửa đổi TextView dưới cùng thành LinearLayout, LinearLayout dưới cùng biến mất.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView
android:textSize="12px"
android:text="something here"
android:layout_width="50px"
android:layout_height="wrap_content"
/>
<TextView
android:textSize="12px"
android:text="something here"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="bottom"
>
<ListView
android:id="@+id/listbody"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<LinearLayout
android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
>
<TextView
android:layout_height="wrap_content"
android:layout_width="0dip"
android:layout_weight="1"
android:textSize="12px"
android:text="50%"
/>
<TextView
android:layout_height="wrap_content"
android:layout_width="0dip"
android:layout_weight="1"
android:textSize="12px"
android:text="50%"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
Mọi người đều có thể cho biết lời khuyên? Xin vui lòng giúp đỡ.
Bây giờ LinearLayout chồng lên với ListView! Tôi nghĩ rằng nó phải là một cái gì đó sai trái trong việc defination của LinearLayout ở phía dưới. – chow
Không phải đặc biệt. Đối với ListView, thêm: \t android: layout_height = "wrap_content" \t android: layout_width = "fill_parent" \t android: layout_below = "@ id/top_linear_layout_id" \t android: layout_above = "@ + id/bottom_linear_layout_id" Cùng với các id tương ứng cho các bố trí tuyến tính. – Estel