title: RecyclerView's GridLayoutManager dynamic span count
body: <p>I am using following code dynamically change span count. </p>
  
  <pre><code>val layoutManager = GridLayoutManager(this, 3)
  layoutManager.spanSizeLookup = object : GridLayoutManager.SpanSizeLookup() {
      override fun getSpanSize(position: Int): Int {
          when (position) {
              0, 1, 2 -&gt; return 1
              3, 4 -&gt; return 2
              5 -&gt; return 3
              else -&gt; return 1
          }
      }
  }
  </code></pre>
  
  <p>And I got following output.
  But I want <strong>D and E</strong> should horizontally equally aligned. I don't how to do it. </p>
  
  <p>Actually I have 3 types in adapter, <strong>HEADER, TYPE_A, TYPE_B</strong>. 
  <strong>HEADER</strong> should have only one row, and <strong>TYPE_A</strong> is 3 rows, <strong>TYPE_B</strong> is 2 rows. </p>
  
  <p>So may I get help to make some columns should have one 1 row, and some have only 2 rows(horizontally equally aligned) and some have 3 rows. </p>
  
  <p><a href="https://i.stack.imgur.com/mw21w.png" rel="noreferrer"><img src="https://i.stack.imgur.com/mw21w.png" alt="enter image description here"></a></p>