adev
adev

Reputation: 377

android Tablelayout out of screen

I'm using tablelayout for an activity. At the start time the layout is fine but when some data populate the fileds on the activity the layout changes its form going outside of the screen. How can I block the layout?

Upvotes: 2

Views: 3679

Answers (2)

yuliskov
yuliskov

Reputation: 1508

Did you try shrinkColumns option?

<TableLayout
android:shrinkColumns="*"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
...

Upvotes: 6

adev
adev

Reputation: 377

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_column="1">

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

        <TableRow
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">


        </TableRow>

        <TableRow>

            <TextView
                android:layout_width="fill_parent"
                android:gravity="left"
                android:text="@string/loc_label" />

            <EditText
                android:id="@+id/editText"
                android:layout_width="fill_parent"
                android:layout_column="2"

                android:gravity="right" />
        </TableRow>

        <TableRow>

            <TextView
                android:layout_width="fill_parent"
                android:padding="3dip"
                android:text="@string/precipMM" />

            <TextView
                android:id="@+id/precipMM_value_tv"
                android:layout_width="fill_parent"
                android:layout_column="2"
                android:gravity="right"
                android:padding="3dip"
                android:text="@string/nodata" />
        </TableRow>

        <TableRow>

            <TextView
                android:layout_width="fill_parent"
                android:padding="3dip"
                android:text="@string/descrWeather" />

            <TextView
                android:id="@+id/descrTV"
                android:layout_width="fill_parent"
                android:layout_column="2"
                android:gravity="right"
                android:padding="3dip"
                android:text="@string/nodata" />
        </TableRow>

        <TableRow>

            <Button
                android:id="@+id/buttonConnect"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_column="0"
                android:text="@string/updateButton"

                />

            <Button
                android:id="@+id/closeButton"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_column="2"

                android:text="@string/closeButton" />
        </TableRow>

        <TableRow
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"></TableRow>

        <TableRow
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"></TableRow>

        <TableRow
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"></TableRow>

        <TableRow
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"></TableRow>

        <TableRow
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"></TableRow>

        <TableRow
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">


        </TableRow>
    </TableLayout>
</RelativeLayout>

Upvotes: 1

Related Questions