0

テーブル レイアウトと内部に 4 つのアイテムを含むこのレイアウトがあります。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

    <TableLayout 
        android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:stretchColumns="0,1,2,3,4,5,6,7"
    android:background="#FF3538">

       <TableRow>

    <TextView
        android:id="@+id/o1"
        android:textStyle="bold"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:text="@string/fecha"
         />



    <TextView
        android:id="@+id/o2"
        android:gravity="center"
        android:textStyle="bold"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/Vv"
        />


    <TextView
        android:id="@+id/o3"
        android:gravity="center"
        android:textStyle="bold"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/Dv"
        />


    <TextView
        android:id="@+id/o4"
        android:gravity="center"
        android:textStyle="bold"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/Ht"
        />

 </TableRow>
  </TableLayout>

  <LinearLayout 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <ListView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/listView"></ListView>
  </LinearLayout>

</LinearLayout>

そして、この別のレイアウト (リストビュー)

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/celda_cabecera" >

    <TableLayout 
        android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:stretchColumns="0,1,2,3,4,5,6,7"
    >

       <TableRow>

    <TextView
        android:id="@+id/o1"
        android:textStyle="bold"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center"

         />

    <TextView
        android:id="@+id/o2"
        android:textStyle="bold"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
         android:gravity="center"

        />

    <ImageView
        android:id="@+id/o3"
        android:contentDescription="@string/dirviento"
        android:textStyle="bold"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"

        />

    <TextView
        android:id="@+id/04"
        android:textStyle="bold"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center"
       />
</TableRow>
    </TableLayout>


</RelativeLayout>

リストビューのアイテムを最初のレイアウトのアイテムに揃えたいのですが、私の解決策はうまくいきません

4

1 に答える 1

2

こんにちは @Er_ 重みの概念を使用する必要があると思います。

以下のビューのように、すべてのビューを置き換えるだけ<TableRow>です。

例:

<TextView
    android:id="@+id/o1"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:gravity="center"
    android:text="@string/fecha"
    android:textStyle="bold" />

したがって、すべての子ビューに同じ重みを与えます<TableRow>

それは私が交換する脅威です、

    android:layout_width="0dp"
    android:layout_weight="1"

それ以外の

    android:layout_width="wrap_content"
于 2014-01-07T13:50:28.030 に答える