0

LinearLayout で 2 つのテーブルを並べて使用していますが、どちらも画面幅の 50% を占めています。その LinearLayout の下には、別のテーブルを含む RelativeLayout があります。

このようなもの:

<LinearLayout>
      <TableLayout>
           <TableRow>
            ...
           </TableRow>
      </TableLayout>

      <TableLayout>
           <TableRow>
            ...
           </TableRow>
      </TableLayout>
</LinearLayout>

<RelativeLayout>

      ... some views ...

      <TableLayout>
           <TableRow>
            ...
           </TableRow>
      </TableLayout>
</RelativeLayout>

ここで、RelativeLayout のテーブルの幅を LinearLayout の最初のテーブルと同じにしたいと考えています。でできると思ったのですandroid:layout_alignRight="@+id/Linearlayout_table1"が、うまくいきません。

それで、これを行う方法はありますか?

4

1 に答える 1

0

RelativeLayout の代わりに LinearLayout を使用し、空の要素を含めて正しい重み付けを提供できます。注: layout_height を任意の値に設定してください。

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <TableLayout
            android:layout_width="0dp"
            android:layout_height="300dp"
            android:layout_weight="1" />

        <TableLayout
            android:layout_width="0dp"
            android:layout_height="300dp"
            android:layout_weight="1" />
    </LinearLayout>

   <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <TableLayout
            android:layout_width="0dp"
            android:layout_height="300dp"
            android:layout_weight="1" />

        <View
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_weight="1" />
    </LinearLayout>
于 2013-05-06T17:07:43.650 に答える