Skip to content Skip to sidebar Skip to footer

Tablelayout Crushes Button

I'm experiencing a strange issue with a TableLayout next to a Button. This is the XML:

Solution 1:

Just add this to your parent. and make width 0dp of both child

android:weightSum="2"

<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="horizontal"android:weightSum="2"><TableLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:id="@+id/tableLayout1"android:layout_width="0dp"android:layout_height="wrap_content"android:layout_weight="1"android:stretchColumns="*"><TableRowandroid:id="@+id/tableRow1"android:layout_width="wrap_content"android:layout_height="wrap_content"><TextViewandroid:id="@+id/textView1"android:text="Column 1" /><Buttonandroid:id="@+id/button1"android:text="Column 2" /></TableRow></TableLayout><Buttonandroid:id="@+id/button2"android:layout_width="0dp"android:layout_height="wrap_content"android:layout_weight="1"android:text="Button 2" /></LinearLayout>

enter image description here

Solution 2:

set android:layout_width="0dp" for both Button and TableLayout

Post a Comment for "Tablelayout Crushes Button"