Skip to content

Instantly share code, notes, and snippets.

@d4vidi
Created July 19, 2018 11:09
Show Gist options
  • Save d4vidi/658807a5981de8fb54bbb376e7a2718f to your computer and use it in GitHub Desktop.
Save d4vidi/658807a5981de8fb54bbb376e7a2718f to your computer and use it in GitHub Desktop.
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val recyclerView = findViewById<RecyclerView>(R.id.recycler_view)
// Usual setups
recyclerView.layoutManager = LinearLayoutManager(activity, LinearLayoutManager.HORIZONTAL, false)
recyclerView.adapter = ...
// Decorator set-up
val cardWidthPixels = activity.resources.displayMetrics.widthPixels * 0.80f
val cardHintPercent = 0.01f
recyclerView.addItemDecoration(RVPagerSnapFancyDecorator(activity, cardWidthPixels, cardHintPercent))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment