Question

Screenshot:

http://i46.tinypic.com/2r44hg3.jpg

As can be seen in the picture above for some reason I get a strange white area of nothing in my listView when using a ScrollView. If I remove the ScrollView the white area of nothing dissapears, but unfortunately I must use the ScrollView in my interface. If I fill my list with items the white "area" is still there and being placed beneath the items instead.

Anyone seen this before? How can I remove it without removing my ScrollView which for some reason makes it appear? Ive tried to change all different type of setting such as fill_parent/wrap_content/0dip without any success so far.

Please help if you know something!

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


<ScrollView 
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent"
android:layout_width="fill_parent">

<TableLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/orginalbild"
android:fillViewport="true"
android:gravity="center|top"
android:orientation="vertical"
android:stretchColumns="1"
android:weightSum="1.0">

<TableRow
    android:paddingTop="3dp" >

 <TextView
             android:layout_width="0dip"
             android:layout_height="fill_parent" 
             android:layout_weight="0.04">
            </TextView>

            <EditText
                android:id="@+id/search_task_field"
                android:layout_width="0dip"
                android:layout_height="fill_parent"
                android:layout_weight="0.7"
                android:hint="@string/SearchTaskHint" 
                />

            <ImageButton
                android:id="@+id/search_task_button"
                android:layout_width="0dip"
                android:layout_height="50dp"
                android:layout_gravity="center"
                android:layout_weight="0.22"

                android:src="@drawable/find3" />

            <TextView
                android:layout_width="0dip"
                android:layout_height="fill_parent" 
                android:layout_weight="0.04"
                android:visibility="invisible"
                >
            </TextView>
          </TableRow>


       <TableRow
    android:paddingTop="0.9dp"
    android:paddingRight="0.9dp"
    android:paddingLeft="0.9dp"
    android:background="#90767878"
    android:paddingBottom="0.9dp"
    android:layout_marginLeft="24dp"
    android:layout_marginRight="24dp"
    android:layout_marginBottom="20dp"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <ListView
        android:id="@+id/search_task_list"
        android:layout_width="0dip"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:background="#FFFFFF"
        android:gravity="left"
         />
</TableRow>  
   </TableLayout>
     </ScrollView>
Was it helpful?

Solution

You can't place an ListView within a ScrollView. Thats not possible. Because then the ListView has got two options to scroll trough the content, as you will. And this won't work.

If you want to display Content under or above a ListView and want it to get scrolled with it you may have to create a custom View.

For more Information:

https://groups.google.com/forum/m/?fromgroups#!topic/android-beginners/LRpLgGOy2Pc

Edit: I would recommend you to use this: https://github.com/thiagolocatelli/android-uitableview Its a custom ListView and you can set it within a ScrollView

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top