title: LayoutManager for RecyclerView to set the number of columns automatically according to width of items
body: <p>I'm trying to build a UI involving RecyclerView or GridView, where i want to set the number of columns automatically depending upon the number and width of the items that i'm populating dynamically.</p>
  
  <p>Here's the image of what i've achieved so far...</p>
  
  <p><a href="https://i.stack.imgur.com/5iBIR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5iBIR.png" alt="my current UI"></a></p>
  
  <p>Here's the image of what i'm trying to achieve...</p>
  
  <p><a href="https://i.stack.imgur.com/g2JaA.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/g2JaA.jpg" alt="my target UI"></a></p>
  
  <p>My item layout xml</p>
  
  <pre><code>&lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="40dp"
          android:background="@drawable/hollow_white_background"
          android:id="@+id/foodItemName"
          android:text="PIZZA"
          android:gravity="center"
          android:textColor="@color/colorGray300"
          android:textStyle="bold"
          android:textSize="15sp"
          android:paddingLeft="10dp"
          android:paddingRight="10dp" /&gt;
  </code></pre>
  
  <p>Please Help!</p>