title: SetGravity for GridLayout not working
body: <p>I am using a simple <code>GridLayout</code> to which I'm adding buttons dynamically. </p>
  
  <pre><code>&lt;GridLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/tagGridLayout"
  android:background="@color/white"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:columnCount="3"
  &gt;
  &lt;/GridLayout&gt;
  </code></pre>
  
  <p>And I am using this Java code to fill my grid which is all working fine except that the set Gravity option doesn't do anything. I've tried - changing layout_width to different types in the XML file, adding gravity to the <code>GridLayout</code> etc. as mentioned in other solutions on this site. Another thing to note is that I am doing this in an Async task inside a Fragment. Basically I want to achieve what <code>layout_gravity="fill_horizontal"</code> achieves in the XML. </p>
  
  <pre><code>tagButtons = new Button[trendingTagsCount];
          for(int i=0;i&lt;trendingTagsCount;i++)
          {
              tagButtons[i] = new Button(getActivity());
              //tagButtons[i].setLayoutParams(new LayoutParams(Gravity.FILL_HORIZONTAL));
              tagButtons[i].setText(getTagsList.get(i).tag);
              tagButtons[i].setGravity(Gravity.FILL_HORIZONTAL);
              tagButtonGrid.addView(tagButtons[i]);
          }
  </code></pre>