Search code examples
androidxmlandroid-layoutxml-parsingxml-layout

Textview on top of tablelayout


How do i get the "Large Text" TextView above my TableLayout. (Red arrow)

Also, how do i close the gap between the rows in my TableLayout. (Brown arrow)

enter image description here


Solution

  • To fix the row padding issue:

    You will need to adjust the padding for each TableRow, please look at the TableRow tags in the xml below. There are different types of padding offered. Just look at the ones offered and decide what is best for your situation.

    To solve the TextView "LargeText" issue:

    Use a LinearLayout and put the TextView above the TableLayout with a vertical orientation on the LinearLayout, please view the layout xml below.

    <?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" >
    
        <TextView
            style="@android:style/TextAppearance.Large"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="LargeText" />
    
        <TableLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent" >
    
            <TableRow>
    
                <TextView
                    android:padding="0dp"
                    android:text="row1_a" />
            </TableRow>
    
            <TableRow>
    
                <TextView
                    android:padding="0dp"
                    android:text="row2_a" />
            </TableRow>
        </TableLayout>
    
    </LinearLayout>