RecyclerView滑动到顶部或者底部时,会有阴影效果,默认情况下是白色的,但有时候项目内有特殊需求时,需要其他颜色,只需要将color中的<color name="colorPrimary">自定义颜色</color> 此属性做修改即可。
我的使用模式是将AndroidManifest.xml中Application的主题替换了,重写了一个主题继承原来使用的主题,在主题内重定义了colorPrimary属性的值
原有:
AndroidManifest.xml:
<application
android:name="***Application"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:persistent="true"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.AppCompat.DayNight.NoActionBar">
显示效果:
现在:
res/values/style.xml:
<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/textSelect</item> <!--@color/textSelect :#D44A2E-->
</style>
AndroidManifest.xml:
<application
android:name="***Application"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:persistent="true"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
效果:
随缘记录Ⅱ