对齐TableLayout中的文本单元格

ury*_*ury 1 android tablelayout

如何在两列TableLayout中对齐文本内容,以使左列中的文本与右侧对齐,左列中的文本与左侧对齐,使它们在中间周围彼此"紧固"屏幕?

它应该看起来像这样:

+-----------------------------------+
|           Title: | Value          |
+-----------------------------------+
Run Code Online (Sandbox Code Playgroud)

Lea*_*oid 5

这是一个提供您想要的小例子

<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <TableRow
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:weightSum="2">
        <TextView
            android:text="left at right"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="right"
            android:paddingRight="5dp" />
        <TextView
            android:text="right at left"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="left"
            android:paddingLeft="5dp" />
    </TableRow>
</TableLayout>
Run Code Online (Sandbox Code Playgroud)