2
votes

ListView has this nice feature where you can set an overscroll header or footer. ScrollView, unfortunately, has no such thing. Does anyone know of a way to put together something that works like a ScrollView with an overscroll header/footer?

2

2 Answers

4
votes

My best guess is you might be able to accomplish this with a similar approach as pull-to-refresh for lists is implemented on Android devices: you basically stretch a view at the top of (probably actually above - same for a 'footer', but then below) the ScrollView to fake an overscroll effect.

For some ideas on this, have a look at this pull-to-refresh implementation. It dynamically adjusts the padding of a header view in the list to simulate it being overscrolled when 'pulling'.

2
votes

Can't you put your ScrollView inside a RelativeLayout, which will also contain the header and footer? Something like this:

<RelativeLayout ...>
    <TextView 
        android:id="@+id/header"
        android:alignParentTop="true"/>
    <ScrollView
        android:id="@+id/scroller"
        android:layout_below="@id/header"
        android:layout_height="fill_parent"/>
    <TextView
        android:id="@+id/footer"
        android:layout_below="@id/scroller"
        android:alignParentBottom="true"/>
</RelativeLayout>

In this question ( Can we use a ScrollView inside a LinearLayout? ), someone showed how to put a ScrollView inside a LinearLayout. It should be the same.