【问题标题】:Recyclerview list end overlay color and alphaRecyclerview 列表结束覆盖颜色和 alpha
【发布时间】:2018-01-08 05:30:50
【问题描述】:

即使到达列表的末尾(顶部或底部),当我们尝试滚动时,如何更改 recyclerview 上出现的灰色或白色叠加层。我找不到可以用来执行此操作的属性名称。

【问题讨论】:

  • 我认为这是滚动中的默认属性。如果您愿意,可以使用样式表。

标签: android listview android-recyclerview


【解决方案1】:

RecyclerView 从您的主题的colorPrimary 中汲取阴影。

您需要为RecyclerView 创建新主题,然后将此主题应用到您的RecyclerView

在下面的示例主题中,colorPrimarycolorGreen,所以它会采用绿色阴影。

示例代码

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

【讨论】:

  • 它显示出来了,但它很沉闷,我需要一个黑暗的,就像我们在 whatsapp 应用程序上一样
  • @ManishPatiyal 确保您在 +21 设备上运行您的应用程序。
【解决方案2】:

在你的 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" />

【讨论】:

  • 其实我想改变它的颜色或者覆盖层的alpha,用你的代码它只是隐藏了覆盖层
【解决方案3】:

使用样式更改该 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);
}

【讨论】:

    猜你喜欢
    • 2012-12-04
    • 2017-01-06
    • 2014-02-06
    • 1970-01-01
    • 1970-01-01
    • 2014-08-02
    • 1970-01-01
    • 2012-11-05
    • 1970-01-01
    相关资源
    最近更新 更多