2012-11-13 35 views

回答

-1

U可以在你的xml文件頁面中使用下面的標籤來對齊,如果可以給出你所面對的pblm的細節,我可以給出更多的解釋。

android:layout_marginLeft="25dp" 
android:layout_below="@+id/imageView1" 

第一個代碼從左側給出25dp的餘量,第二個代碼只是將該字段在imageview1下對齊到右側。

而且還有一個另一種方法,你在設計頁面添加 上的文本視圖或任何只需右鍵點擊選擇其他屬性 - >佈局參數 - >然後選擇你需要的項目[它包含了所有對齊屬性。

希望這個幫助你。謝謝

9

您可以將android:gravity="center_vertical"屬性設置爲TableRow以使其子垂直居中。

您也可以使用android:layout_marginLeft財產或財產android:layout_marginRiight放一些利潤率從左右同樣可以使用android:layout_marginTopandroid:layout_marginBottom把保證金頂部和底部。

如果要拉伸列,則可以使用android:layout_weight屬性來定義列的權重。

僅供參考,你可以看到下面的例子2列

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

    <TableRow 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:gravity="center_vertical" > 

    <TextView 
     android:id="@+id/TextView01" 
     android:layout_width="0dip" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:text="Male" 
     android:textAppearance="?android:attr/textAppearanceMedium" /> 

    <EditText 
     android:id="@+id/etNoOfMale" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:inputType="number"/> 
    </TableRow> 

    <TableRow 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:gravity="center_vertical" > 

    <TextView 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:text="Female" 
     android:textAppearance="?android:attr/textAppearanceMedium" /> 

    <EditText 
     android:id="@+id/etNoOfFemale" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:inputType="number"/> 
    </TableRow> 

</TableLayout> 
+1

謝謝!花了3小時找出:) – yashhy