Как создать 3 одинаково широких TextView, которые заполняют родительский элемент на экране - PullRequest
3 голосов
/ 12 мая 2010

HI

Подскажите, пожалуйста, как мне создать 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 голосов
/ 12 мая 2010
<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>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...