I have this output
http://www.cubixshade.com/images/align_row.jpg
I want first field that is date field to be align vertically center? and what should i use use to add some space from left or right in other field also?
You can set android:gravity="center_vertical"
property to TableRow to align its child vertically center.
Also you can use android:layout_marginLeft
property or android:layout_marginRiight
property to put some margins from left and right similarly you can put margin to top and bottom using android:layout_marginTop
or android:layout_marginBottom
.
If you want to stretched column then you can use the android:layout_weight
property to define the weight of the column.
For reference you can see below example with 2 columns
<?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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With