making the edge of the scrollview fade when scrolling in android

Viewed 33237

I have a ScrollView with an image in it.

I want the edges of the ScrollView to make a fade effect when I scroll the image. I'm not talking about the effect you get when you get to the end of the scroll. I want the fade to always exist.

That's what i did (not doing any effect):

<ScrollView
    android:id="@+id/scrollView1"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="0.84"
    android:background="@drawable/screen_nespresso"
    android:fadingEdge="horizontal"
    android:fadingEdgeLength="@dimen/padding_large"
    android:fillViewport="false"
    android:scrollbarAlwaysDrawVerticalTrack="true"
    android:visibility="visible" >

Thanks!

4 Answers

Add these lines in your ScrollView xml code.

<ScrollView
    android:id="@+id/scrollView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fadeScrollbars="true"
    android:requiresFadingEdge="vertical"
    android:fadingEdgeLength="50dp">

Just add these 3 line of code in scroll view and it will look awesome!

 android:fadingEdgeLength="80dp"
 android:overScrollMode="never"
 android:requiresFadingEdge="vertical"
Related