How do you leave a Tablelayout on a fixed screen size?

Asked

Viewed 340 times

0

I have a screen where it has a title, a table and two buttons at the bottom of the table. I put the table inside a scrollView. However, when the table is filling with lines, it will take the place of the buttons until it disappears. Does anyone know how to solve this? I thank you in advance. Follow an example of my structure:

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

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center" />

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <TableLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:stretchColumns="*" >
        </TableLayout>
    </ScrollView>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <Button
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1" />

        <Button
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1" />
    </LinearLayout>
</LinearLayout>

  • give a android:id to the LinearLayout where there are two buttons. In your <ScrollView>, adicone: android:above:+id/idQueVoceAtribuiuAoLayoutDosBotoes

  • @Marllonnasser above is an attribute of Relativelayout what is being used is a Linearlayout

  • And why not use RelativeLayout?

  • I put the id on all, just took to show here to get cleaner.

1 answer

2


Try adding android:layout_weight="1" to your Scrollview.

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="1" >

    <TableLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:stretchColumns="*" >
    </TableLayout>
</ScrollView>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.