Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android table column width 50 / 50

i have this table layout:

<TableRow 
    android:layout_height="wrap_content" 
    android:layout_width="fill_parent"
    android:gravity="center_horizontal">  
    <TextView 
        android:id="@+id/TextView01" android:text="test"
        android:layout_weight="0.5" android:background="#b0b0b0"
        android:textColor="#000000"
        android:padding="20dip" android:gravity="left"/>

    <TextView 
        android:id="@+id/TextView04" android:text="Row 3 column 2"
        android:layout_weight="0.5" android:background="#a09f9f"
        android:textColor="#000000"
        android:padding="20dip" android:gravity="left"/>  
</TableRow>  

I would like to have each column exactly 50 percent of the width.

How can I do it?

like image 869
redrom Avatar asked Mar 13 '14 15:03

redrom


1 Answers

Use this construction (layout for one row):

<TableRow
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:weightSum="2" >

    <TextView
        android:id="@+id/TextView01"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1" />

    <TextView
        android:id="@+id/TextView04"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"/>

</TableRow>
like image 87
Alex Kucherenko Avatar answered Sep 26 '22 20:09

Alex Kucherenko