Nest TableLayout inside LinearLayout - is it possible?

10,906

in your table layout add these

android:layout_height="80dp"  
 android:layout_weight="1.0"

also for the bottom button and and text view add fixed height.If your table needs more space then put it between scrollView

Share:
10,906
danjarvis
Author by

danjarvis

I'm a PhD student at the Institute for Complex Systems Simulation at the University of Southampton, UK studying complexity in Remote Sensing. As part of my work I am heavily involved in Remote Sensing and GIS technologies - particularly ENVI/IDL programming and ArcGIS scripting using Python. My academic website shows some examples of my work, and links to some of the software I have written.

Updated on June 05, 2022

Comments

  • danjarvis
    danjarvis almost 2 years

    I want to produce an Android screen layout that looks something like the following:

    Label   Text Field
    Label   Text Field
    Label   Text Field
    
    -----Button-------
    -----TextField----
    

    That is, I want to have a TableLayout at the top, with a number of items underneath the table layout (mainly so I can force these items to be at the bottom of the screen). I have tried to nest them as in the code below, but the items at the bottom don't seem to appear.

    Any ideas?

    <?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 xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:stretchColumns="1"
        android:shrinkColumns="1" android:layout_height="wrap_content"  android:layout_gravity="center_vertical">
        <TableRow>
            <TextView android:text="Latitude:"
            android:textAppearance="?android:attr/textAppearanceLarge"
            />
            <TextView android:id="@+id/latitude"
            android:text="Not available"
            android:textAppearance="?android:attr/textAppearanceLarge"
            />
        </TableRow>
        <TableRow>
            <TextView android:text="Longitude:"
            android:textAppearance="?android:attr/textAppearanceLarge"/>
            <TextView android:id="@+id/longitude"
            android:text="Not available"
            android:textAppearance="?android:attr/textAppearanceLarge"/>
        </TableRow>
        <TableRow>
            <TextView android:text="Altitude:"
            android:textAppearance="?android:attr/textAppearanceLarge"/>
            <TextView android:id="@+id/altitude"
            android:text="Not available"
            android:textAppearance="?android:attr/textAppearanceLarge"/>
        </TableRow>
        <TableRow>
            <TextView android:text="Accuracy:"
            android:textAppearance="?android:attr/textAppearanceLarge"/>
            <TextView android:id="@+id/accuracy"
            android:text="Not available"
            android:textAppearance="?android:attr/textAppearanceLarge"/>
        </TableRow>
    </TableLayout>
    <Button android:id="@+id/save"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Save"/>
    <TextView android:text="Test"/>
    </LinearLayout>