title: Android Recyclerview item side by side
body: <p>I have recycler-view with items in it and can be scrolled vertically. Currently what i achieved is items are added one after another like a list. By i need to place them side by side. </p>
  
  <p><strong>Like the image below</strong></p>
  
  <p><a href="https://i.stack.imgur.com/psyiS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/psyiS.png" alt="Target"></a></p>
  
  <p><strong>And my output is</strong> </p>
  
  <p><a href="https://i.stack.imgur.com/SNheY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SNheY.png" alt="Output"></a></p>
  
  <p><strong>My recycler-view setup code:</strong></p>
  
  <pre><code>topicAdapter = new TopicAdapter(topicList, getActivity());
          topicListView.setLayoutManager(new LinearLayoutManager(getActivity()));
          topicListView.setAdapter(topicAdapter);
  </code></pre>
  
  <p><strong>and adapter code is:</strong></p>
  
  <pre><code>public class TopicAdapter extends RecyclerView.Adapter&lt;TopicAdapter.CategoryViewHolder&gt; {
      private List&lt;Topic&gt; topicList;
      Context context;
  
      public TopicAdapter(List&lt;Topic&gt; topicList, Context context) {
          this.topicList = topicList;
          this.context = context;
      }
  
      @Override
      public CategoryViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
          //inflate the layout file
          View groceryProductView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_suggested_topics, parent, false);
          CategoryViewHolder holder = new CategoryViewHolder(groceryProductView);
          return holder;
      }
  
      @Override
      public void onBindViewHolder(CategoryViewHolder holder, final int position) {
          holder.txtview.setText(topicList.get(position).getName());
      }
  
      @Override
      public int getItemCount() {
          return topicList.size();
      }
  
      public class CategoryViewHolder extends RecyclerView.ViewHolder {
          TextView txtview;
  
          public CategoryViewHolder(View view) {
              super(view);
              txtview = view.findViewById(R.id.titleView);
          }
      }
  }
  </code></pre>