/parallaxdecoration

A special item decoration for recyclerView, it can display any bitmaps by looper as background of recyclerView. The bitmaps of background can opt to be scrolled within this recyclerView in a parallax fashion.

Primary LanguageKotlinApache License 2.0Apache-2.0

parallaxdecoration

  • A special item decoration for recyclerView, it can display any bitmaps by looper as background of recyclerView. The bitmaps of background can opt to be scrolled within this recyclerView in a parallax fashion.

  • How to use:

// step1. add config in build.gradle of the root project
allprojects {
    repositories {
        maven { url 'https://www.jitpack.io' }
        google()
        jcenter()
    }
}

// step2. add the library in your app module
implementation 'com.github.seagazer:parallaxdecoration:latestVersion'

// step3. create a parallaxdecoration for your recyclerView
private val bgs = intArrayOf(
    R.drawable.rd_gua_seed_1, R.drawable.rd_gua_seed_2, R.drawable.rd_gua_seed_3
)

val parallaxItemDecoration = ParallaxDecoration(context).apply {
        setupResource(bgs.asList())// init the bitmaps of background
        parallax = 0.3f// set the parallax fashion(the range is [0,1])
        autoFill = true// set the bitmap auto scale to fill the size of recyclerView
    }
recycler_view.addItemDecoration(parallaxItemDecoration)
  • Example demo:

设计原理及使用场景见:https://juejin.cn/post/6903790262183526408