0

Eu tenho uma tela onde tem um título, uma tabela e dois botões em baixo da tabela. Eu coloquei a tabela dentro de um scrollView. Porém, quando a tabela vai enchendo de linhas, ela vai ocupado o lugar dos botões até desaparecer. Alguém sabe como resolver isso? Agradeço desde já. Segue um exemplo da minha estrutura:

<?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>

4
  • dê um android:id para o LinearLayout onde tem os dois botões. No seu <ScrollView>, adicone: android:above:+id/idQueVoceAtribuiuAoLayoutDosBotoes 13/01/2016 às 14:28
  • @MarllonNasser above é um atributo do RelativeLayout o que está a ser utilizado é um LinearLayout
    – ramaral
    13/01/2016 às 15:13
  • E por que não usar RelativeLayout? 13/01/2016 às 16:10
  • eu coloquei o id em todos, só tirei para mostrar aqui para ficar mais limpo. 13/01/2016 às 16:33

1 Resposta 1

2

Tente adicionar android:layout_weight="1" no seu 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>
1

Você deve fazer log-in para responder a esta pergunta.

Esta não é a resposta que você está procurando? Pesquise outras perguntas com a tag .