Reputation: 8001
I am having a problem working with TableLayout. I will explain with the help of screeshots.
I've created the first two rows, each containing two columns.
Then I add the third row which contains only one column, and when I add a lengthy text to that column, it pushes the column 2 of first two rows to the right.
Someone please help me on how to fix it. Regards
here's the code
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="com.cinch.gogch.activities.EmergencyProfileCardActivity"
android:orientation="vertical">
<TextView android:text="Emergency Profile Card"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"/>
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/home_container_shape"
android:paddingLeft="8dp">
<TableRow
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:gravity="center_horizontal"
android:paddingTop="8dp">
<TextView
android:id="@+id/emailTextView"
android:text="[email protected]"
android:layout_weight="5"
android:textColor="#000000"
/>
<LinearLayout android:layout_weight="3">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/dobLabelTextView"
android:text="DOB: "
android:textColor="#000000"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/dobTextView"
android:text="29/06/1991"
android:textColor="#000000"
/>
</LinearLayout>
</TableRow>
<TableRow
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:gravity="center_horizontal"
android:paddingTop="2dp">
<LinearLayout android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_weight="5">
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/genTextView"
android:text="Gender: "
android:textColor="#000000"
/>
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/genderTextView"
android:text="Male"
android:textColor="#000000"
/>
</LinearLayout>
<LinearLayout android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_weight="3">
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/socialTextView"
android:text="SSN: "
android:textColor="#000000"
/>
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/ssnTextView"
android:text="123-42-1412"
android:textColor="#000000"
/>
</LinearLayout>
</TableRow>
<TableRow
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:paddingTop="2dp">
<TextView
android:layout_width="match_parent"
android:id="@+id/addressTextView"
android:text="Akkoor, Sakthikulangara, Kollam"
android:textColor="#000000"
/>
</TableRow>
</TableLayout>/>
</LinearLayout>
If I enter very lengthy text in the third row, this is what it looks like
Upvotes: 0
Views: 88
Reputation: 1373
try to changee the third row like this
<TableRow
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:weightSum="2"
>
<TextView
android:layout_height="wrap_content"
android:layout_width="0dp"
android:id="@+id/addressTextView"
android:text="Akkoor, Sakthikulangara, Kollam"
android:textColor="#000000"
android:layout_weight="1"
/>
<View
android:layout_height="10dp"
android:layout_width="0dp"
android:layout_weight="1"
/>
</TableRow>
Upvotes: 2