Dynamic columns in RecyclerView
<p>i want to create a grid in android wherein suppose </p>

<ol>
<li><a href="http://i.stack.imgur.com/xmUWu.png" rel="nofollow">if i pass an arraylist with 5 elements first row should have 3 columns and next row should have 2 columns with centered</a></li>
<li>if i pass an arraylist with 6 elements first row should have 3 columns and next row should have 3 columns</li>
<li><a href="http://i.stack.imgur.com/5KmA7.png" rel="nofollow">if i pass an arraylist with 7 elements first row should have 3 columns, next row should have 3 columns and next row should have 1 column with centered</a></li>
</ol>