making the edge of the scrollview fade when scroll

2019-01-22 05:52发布

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!

2条回答
Lonely孤独者°
2楼-- · 2019-01-22 06:40

this is for horizental:

<HorizontalScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/scroll"
    android:layout_width="match_parent"
    android:layout_height="match_parent"

    android:requiresFadingEdge="horizontal"
    android:fadingEdgeLength="80dp">
查看更多
叼着烟拽天下
3楼-- · 2019-01-22 06:50

I am not sure if you this working, but here is what worked for me:

<ScrollView android:requiresFadingEdge="vertical">

and in your code, you can do the following

ScrollView scroll = findById(); scroll.setFadingEdgeLength(150);
查看更多
登录 后发表回答