0

I have a RelativeLayout and below that i have a ListView. I have to place these inside a ScrollView. Any help will be deeply appreciated.

simonc
  • 41,632
  • 12
  • 85
  • 103
  • Place the `RelativeLayout` view as the header view of the list. – user Nov 23 '12 at 09:35
  • [Duplicated](http://stackoverflow.com/q/5415011/1050058) , [Duplicated](http://stackoverflow.com/q/4651793/1050058) – Trung Nguyen Nov 23 '12 at 09:39
  • you should not put a listView inside a scrollView. the listView implement its own scrollListener , and it will not responds to events on the scrollView, – Houcine Nov 23 '12 at 09:39

3 Answers3

2

You shouldn't put a ListView inside a ScrollView because the ListView class implements its own scrolling and it just doesn't receive gestures because they all are handled by the parent ScrollView

Ram kiran Pachigolla
  • 20,897
  • 15
  • 57
  • 78
0

ScrollView can be set only for a single Layout. So place the widgets which u want to scroll in a single layout as below:

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

    <RelativeLayout
        android:id="@+id/rltvLyt"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <ListView
            android:id="@+id/lstView"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:textSize="20sp" />
    </RelativeLayout>
</ScrollView>
Avadhani Y
  • 7,566
  • 19
  • 63
  • 90
0

Don't do it. What exactly are you trying to achieve? It had been mentioned here (and everywhere else) this is not a good idea because the scrolling mechanisms get confused as they both want to scroll. Ignoring you however have a listview that is massive then you have missed the major performance gain of using a listview and might swell be using a table layout and add rows.

Paul Harris
  • 5,769
  • 1
  • 25
  • 41
  • Your answer is same as Ram kiran. And if you see this is duplicated, flag question. – Trung Nguyen Nov 23 '12 at 09:34
  • We posted at the same time. Also it might be that what he wants is to use a table layout so I am trying to figure it out because it's possible he is just asking the wrong question in which case we can edit it. I am all for closing questions but sometimes this community is far to happy to do it when all that was wrong is they asked the wrong question and it looks like a duplicate. – Paul Harris Nov 23 '12 at 09:39