2010-05-03 51 views
5

我想要一個tablelayout包含幾個tablerows。其中一行包含4個按鈕,而第二行包含非常長的文本。但是,按鈕的寬度與第二行中的文本一致。無論如何要防止這一點?android:tablerow與列和多行文本混合

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/

這裏是我的xml文件:(不知這個網站是不是友好的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

layout_width和layout_height參數也試圖設置屬性代碼,沒有工作。它是由android的錯誤嗎? – Yang 2010-05-04 16:08:03

回答

3

嘗試使用機器人:layout_span =用於TextView的「4」

用任何可以在第一行的列(按鍵)的數量是..

此外,你可以離開了Android的更換4:從tablerow的

+0

它沒有工作。文本在屏幕外擴展,第一個按鈕仍然很大。 我開始想知道它是否是一個android的bug? – Yang 2010-05-05 20:25:13

+0

它適用於我,這裏是第二行從我身邊工作的XML(可能你把layout_span屬性放在錯誤的地方): 此外,你可以很容易忽略: layout_width = 「WRAP_CONTENT」 layout_height = 「WRAP_CONTENT」 從按鈕和其他tablerow的標籤。 – Anshul 2010-05-07 13:54:24

+0

另外,爲什麼你使用AbsoluteLayout,我不會推薦使用它,除非它絕對必要。 – Anshul 2010-05-07 13:55:22