Wednesday, 14 August 2013

Align EditText at vertical center of a TableRow

Align EditText at vertical center of a TableRow

I am trying to layout some table rows where each table row contains a
caption (TextView widget) and a place to input some text (EditText
widget).
The problem is: I can't make it properly aligned. Text in EditText widget
aligned at the top and I want it to be aligned at the center of the tow.
Here is what it looks like:

Here is the layout I am using:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Test Caption"/>
<EditText
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="This is a test"/>
</TableRow>
</TableLayout>
What am I doing wrong and how can I fix the alignment of the EditText?

No comments:

Post a Comment