Android TableLayout height does not fills the whole screen
Asked Answered
W

1

12

I have a linear layout with just a single TableLayout in it. The Table Layout further has two rows with two columns each. First Table Row has two Images. Second Table Rows has two buttons.

But this does not show up on the complete screen, rather only shows on the first half or maybe depends on the image height. Both the images are actually same file, but shown with different Widths. Help please... here is the Layout file

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

    <TableLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:stretchColumns="*">

        <TableRow
            android:layout_height="fill_parent">

            <ImageView
                android:id="@+id/tp_image"
                android:layout_width="0dip"
                android:layout_height="fill_parent"
                android:layout_weight="0.9"
                android:scaleType="fitXY"
                android:src="@drawable/images" />

            <ImageView 
                android:id="@+id/s_image"
                android:src="@drawable/images"
                android:layout_width="0dip"
                android:layout_height="fill_parent"
                android:scaleType="fitXY"
                android:layout_weight="0.1"
                />
        </TableRow>
        <TableRow >
            <Button 
                android:id="@+id/button_LC"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:text="@string/button_LC"/>
            <Button 
                android:id="@+id/button_RC"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:text="@string/button_RC"/>
        </TableRow>
    </TableLayout>
</LinearLayout>
Waterline answered 24/7, 2012 at 16:35 Comment(0)
T
21

set

<TableRow
    android:layout_height="0dp"
    android:layout_weight="1" >

to both table rows or just to the first row.

Timberlake answered 24/7, 2012 at 16:50 Comment(3)
works like magic after doing this for the first TableRow only...but how ??? What do these attributes do in background ?Waterline
Layout weight explainedTimberlake
Straightforward approachIngraft

© 2022 - 2024 — McMap. All rights reserved.