Thomas Besnehard
Thomas Besnehard

Reputation: 2095

TableLayout button bigger than screen

I'm doing a settings layout with a TableLayout. And all my rows are overfilling the screen. And because an image is easier to understand, here the situation :

enter image description here

Here is a part of the Layout code (I didn't put everything because there is a lot of rows, all the same):

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/ScrollView01"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <TableLayout 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:isScrollContainer="true"
        android:orientation="vertical"
        android:scrollbarAlwaysDrawVerticalTrack="true"
        android:scrollbars="vertical">

        <TableRow
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:padding="5dp" >

            <TextView
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:id="@+id/textIpBox"
                android:text="@string/ipAddress" />

        </TableRow>

        <TableRow
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:padding="5dp" >

            <View
                android:id="@+id/dividerIpbox"
                android:background="@android:drawable/divider_horizontal_dim_dark" />

        </TableRow>

        <TableRow
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:padding="5dp" >

            <TextView
                android:id="@+id/textPortSend"
                android:text="@string/sendPort" />

        </TableRow>

        <TableRow
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:padding="5dp" >

            <EditText
                android:id="@+id/entryPortSend"
                android:inputType="number"
                android:background="@android:drawable/editbox_background" />

        </TableRow>

        <TableRow
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:padding="5dp" >

            <View
                android:id="@+id/dividerPortSend"
                android:background="@android:drawable/divider_horizontal_dim_dark" />

        <TableRow
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:padding="5dp" >

            <Spinner
                android:id="@+id/spinner"
                android:prompt="@string/home_page" />

        </TableRow>

        <TableRow
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:padding="5dp" >

            <TextView
                android:id="@+id/textCurrentWifi"
                android:text="@string/currentWifi" />

        </TableRow> 

        <TableRow
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:padding="5dp" >

            <Button
                android:id="@+id/buttonSave"
                android:text="@string/validate" />
        </TableRow>

    </TableLayout >

</ScrollView>

I'm missing some thing certainly around android:layout_width="fill_parent" but I can't see what.

I didn't quite understand why it's isn't working, when all my layout_width are set to fill_parent

Upvotes: 3

Views: 790

Answers (2)

sammysounder
sammysounder

Reputation: 316

I disagree. This may have solved the problem, but changing a linear layout to a table layout doesn't fix the table layout.
Try

android:stretchColumns = "1,2,3"
android:shrinkColumns = "1,2,3"

This will tell the app which columns should expand/shrink to fit the screen.

Upvotes: 2

Mike Bryant
Mike Bryant

Reputation: 2465

I've found the problem, try changing your TableLayout to a LinearLayout

<LinearLayout 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:isScrollContainer="true"
    android:orientation="vertical"
    android:scrollbarAlwaysDrawVerticalTrack="true"
    android:scrollbars="vertical">

Upvotes: 1

Related Questions