<span style="color:#ff0000;">使用GridLayout实现表单标签左对齐、使用TableLayout实现表单标签右对齐</span>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.judge.gridlayouttest.MainActivity">
<GridLayout
android:id="@+id/gridLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:rowCount="2"
android:columnCount="2"
>
<TextView
android:gravity="right"
android:text="用户名"
android:textSize="20sp"
/>
<EditText
android:hint="请输入用户名"
android:layout_gravity="fill_horizontal"
/>
<TextView
android:text="密码"
android:textSize="20sp"
android:gravity="right"
/>
<EditText
android:hint="请输入用户密码"
android:layout_gravity="fill_horizontal"
/>
</GridLayout>
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/gridLayout"
android:stretchColumns="1"
>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:gravity="right"
android:text="用户名"
android:textSize="20sp"
/>
<EditText
android:hint="请输入用户名"
/>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:text="密码"
android:textSize="20sp"
android:gravity="right"
/>
<EditText
android:hint="请输入用户密码"
/>
</TableRow>
</TableLayout>
</RelativeLayout>
效果图: