title: Scroll multiple items in RecyclerView at the same time like carousel
body: <p>I would like to use RecyclerView like a carousel for display 3 items at the same time on the screen.</p>
  
  <p>So first, on the the screen, it display the items #1 #2 and #3.
  When I swipe the RecyclerView (like a ViewPager) I would like to display items #4 #5 et #6 like this :</p>
  
  <ul>
  <li>The first screen</li>
  </ul>
  
  <p><a href="https://i.stack.imgur.com/iqPDS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iqPDS.png" alt="enter image description here"></a></p>
  
  <ul>
  <li>The screen after the scroll</li>
  </ul>
  
  <p><a href="https://i.stack.imgur.com/9wqz9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9wqz9.png" alt="enter image description here"></a></p>
  
  <p>How to achieve this workflow ? Thanks you for your help !</p>
  
  <p>Here is my <em>Activity</em> </p>
  
  <pre><code>public class CarouselActivity extends BaseActivity {
  
  private RecyclerView recyclerView;
  
  @Override
  protected int getLayoutResourceId() {
      return R.layout.carousel_activity;
  }
  
  @Override
  protected void setupViews()
  {
      recyclerView = (RecyclerView)findViewById(R.id.recyclerview);
  }
  
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      ArrayList&lt;CarouselItem&gt; items = new ArrayList&lt;&gt;();
  
      items.add(new CarouselItem());
      items.add(new CarouselItem());
      items.add(new CarouselItem());
      items.add(new CarouselItem());
      items.add(new CarouselItem());
      items.add(new CarouselItem());
  
  
      recyclerView.setLayoutManager(new LinearLayoutManager(context,LinearLayoutManager.HORIZONTAL,false));
      recyclerView.setHasFixedSize(true);
      recyclerView.setAdapter(new CarouselAdapter(context,activity,items));
  }
  }
  </code></pre>
  
  <p>And my <em>Adapter</em></p>
  
  <pre><code>public class CarouselAdapter extends RecyclerView.Adapter&lt;RecyclerView.ViewHolder&gt; {
  
  protected ArrayList&lt;CarouselItem&gt; listItems;
  
  protected Context context;
  protected Activity activity;
  protected LayoutInflater inflater;
  
  public CarouselAdapter(Context context,
                         Activity activity,
                         ArrayList&lt;CarouselItem&gt; listItems)
  {
      this.context = context;
      this.activity = activity;
      this.inflater = LayoutInflater.from (context);
      this.listItems = listItems;
  }
  
  @Override
  public int getItemCount()
  {
      return listItems.size();
  }
  
  @Override
  public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
  {
      View v = inflater.inflate(R.layout.carousel_item, parent, false);
  
      return new ItemHolder(v);
  }
  
  @Override
  public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position)
  {
      ItemHolder itemHolder = (ItemHolder)holder;
  
      itemHolder.itemView.getLayoutParams().width = ScreenHelper.getScreenWidthRatio(activity,33);
      itemHolder.itemView.getLayoutParams().height = ScreenHelper.getScreenWidthRatio(activity,50);
  
      itemHolder.itemView.setBackgroundColor((position % 2 == 0 ) ? Color.RED : Color.BLUE);
  
      int page = position + 1;
      itemHolder.tvPage.setText("" + page);
  }
  
  protected static class ItemHolder extends RecyclerView.ViewHolder
  {
      private TextView tvPage;
  
      public ItemHolder(View itemView)
      {
          super(itemView);
  
          tvPage = (TextView)itemView.findViewById(R.id.tv_page);
      }
  }
  }
  </code></pre>