f4bzen f4bzen - 23 days ago 16
Android Question

Two TableLayouts side by side

Is it possible to display two TableLayouts (in a RelativeLayout) side by side so that both tables have the same width? I just don't know how to do that. I already tried it with setting

android:stretchColumns="*"
to both tables, but it's just stretching one table to 100% width and the second table gets pushed out of the screen.

Answer

You probably could do that with a LinearLayout and setting each TableLayout weight to 0.5

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >
    <TableLayout
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.5" />
    <TableLayout
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.5" />
</LinearLayout>
Comments