0

I would like to make a layout with a search area and a ListView into a ScrollView for both.

But the ListView doesn't fill the layout ><

Code:

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

    <ScrollView
        android:id="@+id/scrollView1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:orientation="vertical" >

            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" >

                <EditText
                    android:id="@+id/edt_procura_cliente"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:layout_weight="1"
                    android:ems="10" />

                <Button
                    android:id="@+id/button1"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:layout_weight="2.3"
                    android:lines="1"
                    android:text="Procurar" />
            </LinearLayout>


            <ListView
                android:id="@+id/list_clientes_visitas"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent" >

            </ListView>
        </LinearLayout>
    </ScrollView>

</RelativeLayout>    
Guilherme Gregores
  • 1,050
  • 2
  • 10
  • 27
  • remove the scrollview. As said by blackbelt listview has its own scrolling. – Raghunandan Feb 28 '13 at 14:51
  • But I want the whole layout goes down , when I scroll down. – Guilherme Gregores Feb 28 '13 at 16:12
  • If I set the height of the ListView (android:layout_height="500dp" ) it works like I want but , it could have some empty space in the bottom. – Guilherme Gregores Feb 28 '13 at 16:13
  • using layoutweight for listview. it will fill space at the bottom. I din't get your commnet-- But I want the whole layout goes down , when I scroll down – Raghunandan Feb 28 '13 at 17:14
  • If I remove the ScrollView the search area is gonna be fixed in the top and I don't want that. When a scroll down the search area should disappears. – Guilherme Gregores Feb 28 '13 at 17:25
  • most of the apps have a search at the top. ur listview should scroll. I am not sure why you want search to scroll down. I don't know if this works. you can remove the view . when scrolling add view at the bottom. I haven't tried. I am sure others can give a better solution. – Raghunandan Feb 28 '13 at 17:28

2 Answers2

1

You can not put a ListView inside a ScrollView. The ListView has its own scrolling.

Blackbelt
  • 156,034
  • 29
  • 297
  • 305
0

Found a solution for it, here:How can I put a ListView into a ScrollView without it collapsing?

Works fine for me

Community
  • 1
  • 1
Guilherme Gregores
  • 1,050
  • 2
  • 10
  • 27