johng
johng

Reputation: 1026

TextView will not fill parent width

I have a table layout, with two rows.

The width of the Textview will not fill the entire width of the Table row however it fills the height just fine.

The table row is the correct size, filling half the height and the entire width.

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <TableRow
        android:id="@+id/tableRow1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1" >

        <TextView
            android:id="@+id/textView1"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:text="Large Text"
            android:textAppearance="?android:attr/textAppearanceLarge" />

    </TableRow>

    <TableRow
        android:layout_weight="1"
        android:id="@+id/tableRow2"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >
    </TableRow>

</TableLayout>

Upvotes: 1

Views: 4284

Answers (2)

Lingeshwaran
Lingeshwaran

Reputation: 579

add to your textview

android:layout_weight="1"

Upvotes: 8

Sergey Shustikov
Sergey Shustikov

Reputation: 15821

Try this :

<TableRow
    android:id="@+id/tableRow1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="Large Text"
        android:textAppearance="?android:attr/textAppearanceLarge" />

</TableRow>

<TableRow
    android:layout_weight="1"
    android:id="@+id/tableRow2"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
</TableRow>

or change layout size to fill_parent

    <TextView
        android:id="@+id/textView1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:text="Large Text"
        android:textAppearance="?android:attr/textAppearanceLarge" />

Upvotes: 2

Related Questions