Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. package com.yabahddou.pagersnapdemo
  2.  
  3. import android.os.Bundle
  4. import androidx.appcompat.app.AppCompatActivity
  5. import androidx.recyclerview.widget.LinearLayoutManager
  6. import androidx.recyclerview.widget.PagerSnapHelper
  7. import androidx.recyclerview.widget.RecyclerView
  8. import kotlinx.android.synthetic.main.activity_main.*
  9.  
  10. class MainActivity : AppCompatActivity() {
  11.  
  12. override fun onCreate(savedInstanceState: Bundle?) {
  13. super.onCreate(savedInstanceState)
  14. setContentView(R.layout.activity_main)
  15.  
  16. recyclerView.layoutManager = LinearLayoutManager(this, RecyclerView.HORIZONTAL, false)
  17. PagerSnapHelper().attachToRecyclerView(recyclerView)
  18. recyclerView.adapter = ProductsAdapter(10)
  19. recyclerView.addItemDecoration(PagerMarginItemDecoration(horizontalMargin = 8.dp2px, adjacentVisibleSize = 16.dp2px))
  20. }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement