CLOSED 如何在不禁用 fadingEdge 的情况下设置 overScrollMode=never?
CLOSED How to set overScrollMode=never without disable fadingEdge?
我有一个 RecyclerView。我需要设置 overScrollMode = "never" 的值来移除 this animation ,但同时 fadingEdge 选项被禁用。你能帮我关闭我上面写的动画,而不禁用 fadingEdge 吗?
解决方案
如果您在 XML 中执行此操作,那么当您禁用 OverScrollMode - 淡入淡出也变得不可访问,但如果您以编程方式执行此操作,一切都会正常。
recyclerView.setOverScrollMode(View.OVER_SCROLL_NEVER);
recyclerView.setVerticalFadingEdgeEnabled(true);
recyclerView.setFadingEdgeLength(Math.round(30 * Resources.getSystem().getDisplayMetrics().density));
解决方案 2
@RakeshKumar 提出了 XML 的选项。为了让fading不消失,还必须给RecyclerView指定背景。
android:background="YOUR COLOR"
android:fadingEdgeLength="30dp"
android:requiresFadingEdge="vertical"
android:overScrollMode="never"
您可以像下面这样使用它:
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:overScrollMode="never"
android:background="#ffffff"
android:layout_height="wrap_content"
android:scrollbars="vertical"
android:fadingEdgeLength="30dp"
android:requiresFadingEdge="vertical"/>
我有一个 RecyclerView。我需要设置 overScrollMode = "never" 的值来移除 this animation ,但同时 fadingEdge 选项被禁用。你能帮我关闭我上面写的动画,而不禁用 fadingEdge 吗?
解决方案
如果您在 XML 中执行此操作,那么当您禁用 OverScrollMode - 淡入淡出也变得不可访问,但如果您以编程方式执行此操作,一切都会正常。
recyclerView.setOverScrollMode(View.OVER_SCROLL_NEVER);
recyclerView.setVerticalFadingEdgeEnabled(true);
recyclerView.setFadingEdgeLength(Math.round(30 * Resources.getSystem().getDisplayMetrics().density));
解决方案 2
@RakeshKumar 提出了 XML 的选项。为了让fading不消失,还必须给RecyclerView指定背景。
android:background="YOUR COLOR"
android:fadingEdgeLength="30dp"
android:requiresFadingEdge="vertical"
android:overScrollMode="never"
您可以像下面这样使用它:
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:overScrollMode="never"
android:background="#ffffff"
android:layout_height="wrap_content"
android:scrollbars="vertical"
android:fadingEdgeLength="30dp"
android:requiresFadingEdge="vertical"/>