【发布时间】:2018-01-08 05:30:50
【问题描述】:
即使到达列表的末尾(顶部或底部),当我们尝试滚动时,如何更改 recyclerview 上出现的灰色或白色叠加层。我找不到可以用来执行此操作的属性名称。
【问题讨论】:
-
我认为这是滚动中的默认属性。如果您愿意,可以使用样式表。
标签: android listview android-recyclerview
即使到达列表的末尾(顶部或底部),当我们尝试滚动时,如何更改 recyclerview 上出现的灰色或白色叠加层。我找不到可以用来执行此操作的属性名称。
【问题讨论】:
标签: android listview android-recyclerview
RecyclerView 从您的主题的colorPrimary 中汲取阴影。
您需要为RecyclerView 创建新主题,然后将此主题应用到您的RecyclerView
在下面的示例主题中,colorPrimary 是 colorGreen,所以它会采用绿色阴影。
示例代码
<android.support.v7.widget.RecyclerView
android:id="@+id/ha_citiesRC"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:requiresFadingEdge="vertical"
android:theme="@style/CustomTheme"
android:nestedScrollingEnabled="false" />
主题
<style name="CustomTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/colorGreen</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
【讨论】:
在你的 RecylerView 中试试这个
android:overScrollMode="never"
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:overScrollMode="never"
android:background="#000"
android:scrollbars="vertical" />
【讨论】:
使用样式更改该 Activity 和 Fragment 的 ColorPrimary 首先创建样式
<style name="RecyclerView" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">"Enter the Color Which you want"</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
然后只需将样式设置为 Activity
@Override
protected void onCreate(Bundle savedInstanceState) {
setTheme(R.style.RecyclerView);
setContentView(R.layout.activity_home);
super.onCreate(savedInstanceState);
}
【讨论】: