如何创建三个等宽的TextView,填满屏幕的父容器

3

你好,

请问我该如何创建三个等宽的TextView,使其填充整个屏幕?我已经尝试过了,但是TextView的宽度不同:分别为149、89、89。

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="fill_parent" android:layout_height="wrap_content"
     android:stretchColumns="*"
     android:shrinkColumns="*">

<TextView android:id="@+id/t1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_column="0"/>

<TextView android:id="@+id/t2"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_column="1"/>

<TextView android:id="@+id/t3"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_column="2"/>

1个回答

7
<LinearLayout
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"
    >
    <TextView
        android:layout_height="wrap_content"
        android:layout_width="0dp"
        android:layout_weight="1"
    />
    <TextView
        android:layout_height="wrap_content"
        android:layout_width="0dp"
        android:layout_weight="1"
    />
    <TextView
        android:layout_height="wrap_content"
        android:layout_width="0dp"
        android:layout_weight="1"
    />
</LinearLayout>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接