2010-05-03 24 views
5

Tôi đang cố gắng để có tablelayout chứa một số tablerows. Một trong các hàng chứa 4 nút, trong khi hàng thứ hai chứa văn bản rất dài. Tuy nhiên, chiều rộng của nút trải dài với văn bản trong hàng thứ hai. Có cách nào để ngăn chặn điều này?android: tablerow trộn với các cột và văn bản nhiều dòng

alt text http://i40.tinypic.com/34srli0.jpgalt text http://i44.tinypic.com/2505dmf.jpg

http://img684.imageshack.us/i/tableview1.jpg/

http://img521.imageshack.us/i/tableview2.jpg/

Đây là tập tin xml của tôi: (bằng cách nào đó trang web này là không thân thiện với file xml)

AbsoluteLayout 
android:id="@+id/widget0" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
xmlns:android="http://schemas.android.com/apk/res/android" 
> 

TableLayout 
android:id="@+id/widget28" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:orientation="vertical" 
android:layout_x="0px" 
android:layout_y="10px" 
> 

TableRow 
android:id="@+id/widget29" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:orientation="horizontal" 
> 

Button 
android:id="@+id/widget30" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:text="Button" 
> 
</Button> 

Button 
android:id="@+id/widget31" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:text="Button" 
> 
</Button> 

Button 
android:id="@+id/widget32" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:text="Button" 
> 
</Button> 

Button 
android:id="@+id/widget33" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:text="Button" 
> 
</Button> 
</TableRow> 

TableRow 
android:id="@+id/widget35" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:orientation="horizontal" 
> 

TextView 
android:id="@+id/widget40" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:text="TextViewTextViewTextViewTextViewTextViewTextView" 
> 
</TextView> 
</TableRow> 

</TableLayout> 
</AbsoluteLayout> 
+0

Cũng cố gắng để thiết lập các thuộc tính trong mã, không hoạt động. Có phải là một lỗi của android? – Yang

Trả lời

3

hãy thử sử dụng android: layout_span = "4" cho TextView

Thay 4 bởi bất cứ điều gì được số cột (nút) trong hàng đầu tiên là ..

Ngoài ra, bạn có thể bỏ qua android: layout_width và các thông số layout_height từ Tablerow

+0

Nó không hoạt động. Các văn bản strentched ouside màn hình, nút đầu tiên vẫn còn lớn. Tôi bắt đầu tự hỏi liệu đó có phải là lỗi của Android không? – Yang

+0

Nó hoạt động cho tôi, đây là XML làm việc cho hàng thứ 2 từ phía tôi (có lẽ bạn đặt thuộc tính layout_span ở sai vị trí): Ngoài ra, bạn có thể dễ dàng bỏ qua: layout_width = "wrap_content" layout_height = "wrap_content" từ Button và thẻ tablerow khác. – Anshul

+0

Ngoài ra, tại sao bạn sử dụng một AbsoluteLayout, tôi sẽ không khuyên bạn nên sử dụng nó trừ khi sự cần thiết tuyệt đối của nó. – Anshul

Các vấn đề liên quan