making the edge of the scrollview fade when scrolling in android

霸气de小男生 提交于 2019-11-27 11:31:27

问题


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!


回答1:


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);



回答2:


this is for horizontal:

<HorizontalScrollView
    android:id="@+id/scroll"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:requiresFadingEdge="horizontal"
    android:fadingEdgeLength="80dp">


来源:https://stackoverflow.com/questions/11538873/making-the-edge-of-the-scrollview-fade-when-scrolling-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!