How to change the color of overscroll edge and overscroll glow

前端 未结 4 1641
小鲜肉
小鲜肉 2020-12-14 14:55

How to Change color of over-scroll edge and over-scroll glow or how to change the white color (default color) of android release 5.0 lollipop?

4条回答
  •  醉酒成梦
    2020-12-14 15:32

    If you're using the latest RecyclerView implementation it is pretty straightforward to change the overflow colour programmatically. Use the following code (Kotlin implementation):

    recyclerView.edgeEffectFactory = object : RecyclerView.EdgeEffectFactory() {
        override fun createEdgeEffect(view: RecyclerView, direction: Int): EdgeEffect {
            return EdgeEffect(view.context).apply { setColor(color) }
        }
    }
    

    Note that this works only for API level 21 (Lollipop) and above. If you know the value at compile time, use the colorEdgeEffect as pointed out by Ahmed.

提交回复
热议问题