Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.yabahddou.pagersnapdemo
- import android.os.Bundle
- import androidx.appcompat.app.AppCompatActivity
- import androidx.recyclerview.widget.LinearLayoutManager
- import androidx.recyclerview.widget.PagerSnapHelper
- import androidx.recyclerview.widget.RecyclerView
- import kotlinx.android.synthetic.main.activity_main.*
- class MainActivity : AppCompatActivity() {
- override fun onCreate(savedInstanceState: Bundle?) {
- super.onCreate(savedInstanceState)
- setContentView(R.layout.activity_main)
- recyclerView.layoutManager = LinearLayoutManager(this, RecyclerView.HORIZONTAL, false)
- PagerSnapHelper().attachToRecyclerView(recyclerView)
- recyclerView.adapter = ProductsAdapter(10)
- recyclerView.addItemDecoration(PagerMarginItemDecoration(horizontalMargin = 8.dp2px, adjacentVisibleSize = 16.dp2px))
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement