2012-07-16 64 views
0

我有一個表格視圖,裏面有一些空的按鈕。當我運行我的應用程序時,所有按鈕都擠在頂部。我該如何強制桌子佔據整個屏幕區域?如何強制一個tableview使用所有的屏幕空間?

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="vertical" > 
<TableRow 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    > 
    <Button 
     android:id="@+id/button1" 
     /> 
</TableRow> 

我的佈局實際上是相當大的,所以這只是它的

+2

你試圖創建什麼樣的佈局?可能的快照請 – 2012-07-16 14:03:25

+1

發佈您的代碼。 – 2012-07-16 14:03:50

+0

也發佈XML佈局。 – 2012-07-16 14:04:34

回答

1
<TableLayout android:stretchColumns="*" ... > 

取而代之的是*的,你可以指定列被streched,例如「1」或「1,2,3」

1

樣品當我從你的問題了解這裏就是答案:

你可以到行給予重力。像:

<?xml version="1.0" encoding="utf-8"?> 
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/tableLayout1" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 

<TableRow 
    android:id="@+id/tableRow1" 
    android:layout_width="fill_width" 
    android:layout_height="wrap_content" 
    android:gravity = 1.0 > 
    <Button 
     android:id="@+id/button1" 
     android:text="button" /> 
</TableRow> 

<TableRow 
    android:id="@+id/tableRow2" 
    android:layout_width="fill_width" 
    android:layout_height="wrap_content" 
    android:gravity = 1.0 > 
    <Button 
     android:id="@+id/button1" 
     android:text="button" /> 
</TableRow> 

相關問題