我有这个输出
http://www.cubixshade.com/images/align_row.jpg
我想要第一个字段是日期字段垂直对齐中心?我应该用什么来在其他领域左右添加一些空间呢?
Dha*_*dra 10
您可以将android:gravity="center_vertical"属性设置为TableRow以使其子项垂直居中.
您也可以使用android:layout_marginLeft属性或android:layout_marginRiight属性从左侧和右侧放置一些边距,类似地您可以使用android:layout_marginTop或将边距放到顶部和底部android: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>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11744 次 |
| 最近记录: |