arberb
arberb

Reputation: 960

Edittext not filling parent

so I am trying to make a textbook with a submit button using the table layout for my fragment but the issue is the textbook is becoming the size of the button. It is not filling the width

<?xml version="1.0" encoding="utf-8"?>
<TableLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal">

        <TableRow
            android:id="@+id/tableRow1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >

            <EditText
                android:id="@+id/editText1"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:inputType="textUri" />

        </TableRow>

        <TableRow
            android:id="@+id/tableRow3"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >

            <Button
                android:id="@+id/button_as"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="As" />

        </TableRow>

</TableLayout>

what am I doing wrong?

Upvotes: 0

Views: 788

Answers (1)

Chirag Shah
Chirag Shah

Reputation: 3674

Currently, the entire column's width is defined by the subsequent Button's width. This is because that Button is the widest in the column.

Within your TableLayout element, you want to mark the first column (index 0) as stretchable by declaring android:stretchColumns.

<TableLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal"
    android:stretchColumns="0">

Upvotes: 1

Related Questions