在android中滚动时使scrollview的边缘渐渐消失

问题描述 投票:35回答:2

我有一个带有图像的ScrollView

当我滚动图像时,我希望ScrollView的边缘产生淡入淡出效果。我不是在谈论你到达卷轴末尾时所获得的效果。我希望淡入淡出永远存在。

这就是我所做的(没有做任何影响):

<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" >

谢谢!

android scrollview fade
2个回答
83
投票

我不确定你是否正常工作,但这对我有用:

<ScrollView android:requiresFadingEdge="vertical">

在您的代码中,您可以执行以下操作

ScrollView scroll = findById(); scroll.setFadingEdgeLength(150);

2
投票

这是横向的:

<HorizontalScrollView
    android:id="@+id/scroll"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:requiresFadingEdge="horizontal"
    android:fadingEdgeLength="80dp">
© www.soinside.com 2019 - 2024. All rights reserved.