title: How to use recyclerview smothScrollToPosition in a viewpager
body: <p>I use a <strong>recyclerview</strong> in a <strong>viewpager</strong> an when I want to scroll to a position using <strong>smothScrollToPosition</strong> I see no change in the current page but when I slide I see that the change has been applied to the next or the previous page. I have define a function in the <strong>sliderAdapter</strong> call <strong>scrollTo</strong> in this method I call <strong>smothScrollToPosition</strong>.The method <strong>scrollTo</strong> is call when the user click on a button in the <strong>MainActivity</strong></p>
  
  <p><strong>MainActivity</strong></p>
  
  <pre><code>class MainActivity : AppCompatActivity() {
  
  override fun onCreate(savedInstanceState: Bundle?) {
      super.onCreate(savedInstanceState)
      setContentView(R.layout.activity_main)
  
  
      val pager = findViewById&lt;ViewPager&gt;(R.id.view_pager)
      val adapter = SlideAdapter(this)
  
      pager.adapter = adapter
  
      findViewById&lt;Button&gt;(R.id.button).setOnClickListener {
          adapter.scrollTo(30)
      }
  }
  </code></pre>
  
  <p>}
  <strong>SlideAdapter</strong></p>
  
  <pre><code>class SlideAdapter(val context: Context) : PagerAdapter()  {
  
  lateinit var recyclerView: RecyclerView
  lateinit var viewManager : LinearLayoutManager
  
  fun scrollTo(position: Int) {
      viewManager.scrollToPositionWithOffset(position, 0)
  }
  
  override fun isViewFromObject(view: View, `object`: Any): Boolean = view == `object` as RelativeLayout
  
  override fun getCount() = 5
  
  override fun instantiateItem(container: ViewGroup, position: Int): Any {
      val view = LayoutInflater.from(context)
              .inflate(R.layout.slide, container, false) as RelativeLayout
  
  
      val list = mutableListOf&lt;String&gt;()
  
      for (i in 0..50)
          list.add("Element $i")
  
      val viewAdapter = Adapter(context, list)
      viewManager = LinearLayoutManager(context)
      recyclerView = view.findViewById(R.id.recyclerView)
  
      recyclerView.apply {
          setHasFixedSize(true)
          layoutManager = viewManager
          adapter = viewAdapter
      }
  
      container.addView(view)
  
      return view
  }
  
  override fun destroyItem(container: ViewGroup, position: Int, `object`: Any) {
      container.removeView(`object` as RelativeLayout)
  }
  </code></pre>
  
  <p>}</p>
  
  <p><a href="https://i.stack.imgur.com/i7N2U.jpg" rel="nofollow noreferrer">IMAGE PAGE 1</a>  I CLICK ON THE BUTTON AND I SEE NO CHANGE</p>
  
  <p><a href="https://i.stack.imgur.com/80aUy.jpg" rel="nofollow noreferrer">IMAGE PAGE 2</a>  I SLIDE AND SEE THAT THE CHANGE HAS BEEN APPLIED ON THIS PAGE. </p>
  
  <p>I need help please <em>^_^</em></p>