title: GridView's children are not extending to the edge of the GridView
body: <p>I am trying to make a custom calendar view</p>
  
  <p>When I add <code>TextViews</code> to fill up a <code>GridView</code> they don't expand all the way to the edge of the screen even though everything is set to match parent. </p>
  
  <p>The issue can be seen below on the right side of the emulator screen:
  <a href="https://i.stack.imgur.com/tCErj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tCErj.png" alt="enter image description here"></a></p>
  
  <p>The following are the XML layout files I am using:</p>
  
  <p>calendar.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="match_parent"
  android:layout_height="match_parent"&gt;
  
      &lt;GridView
          android:id="@+id/calendar_grid"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:background="@color/dateBorder"
          android:verticalSpacing="1dp"
          android:horizontalSpacing="1dp"
          android:numColumns="7"
          /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>calendar_day.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;TextView xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/calendar_day"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:padding="10dp"
      android:gravity="right"
      android:textAppearance="@android:style/TextAppearance.Medium"&gt;
  &lt;/TextView&gt;
  </code></pre>
  
  <p>activity_main.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:fitsSystemWindows="true"&gt;
  
      &lt;niddahcalendar.kosherapps.com.testgridview.MyCalendarView
          android:id="@+id/my_calendar_view"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"&gt;
      &lt;/niddahcalendar.kosherapps.com.testgridview.MyCalendarView&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>This is the java code I am using:</p>
  
  <p>MyCalendarView.java</p>
  
  <pre><code>import android.content.Context;
  import android.util.AttributeSet;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.BaseAdapter;
  import android.widget.GridView;
  import android.widget.LinearLayout;
  import android.widget.TextView;
  
  import java.util.ArrayList;
  import java.util.Calendar;
  
  public class MyCalendarView extends LinearLayout{
  
      GridView grid;
  
      public MyCalendarView(Context context) {
          super(context);
          init(context);
          updateCalendar();
      }
  
      public MyCalendarView(Context context, AttributeSet attrs) {
          super(context, attrs);
          init(context);
          updateCalendar();
      }
  
      public MyCalendarView(Context context, AttributeSet attrs, int defStyleAttr) {
          super(context, attrs, defStyleAttr);
          init(context);
          updateCalendar();
      }
  
      private void init(Context context) {
          LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          inflater.inflate(R.layout.calendar, this);
          grid = (GridView)findViewById(R.id.calendar_grid);
      }
  
      public void updateCalendar() {
          final ArrayList&lt;Integer&gt; calendarDays = new ArrayList&lt;&gt;();
          Calendar calendar = Calendar.getInstance();
          int monthBeginningCell = calendar.get(Calendar.DAY_OF_WEEK) - 1;
          calendar.add(Calendar.DAY_OF_MONTH, -monthBeginningCell);
          while (calendarDays.size() &lt; 42) {
              int day = calendar.get(Calendar.DAY_OF_MONTH);
              calendarDays.add(day);
              calendar.add(Calendar.DAY_OF_MONTH, 1);
          }
          CalendarAdapter calendarAdapter = new CalendarAdapter(this.getContext(), calendarDays);
          grid.setAdapter(calendarAdapter);
      }
  
      class CalendarAdapter extends BaseAdapter {
  
          private Context context;
          private ArrayList&lt;Integer&gt; calendarDays;
  
          public CalendarAdapter(Context context, ArrayList&lt;Integer&gt; calendarDays) {
              this.context = context;
              this.calendarDays = calendarDays;
          }
  
          @Override
          public int getCount() {
              return calendarDays.size();
          }
  
          @Override
          public Object getItem(int position) {
              return calendarDays.get(position);
          }
  
          @Override
          public long getItemId(int position) {
              return 0;
          }
  
          @Override
          public View getView(int position, View convertView, ViewGroup parent) {
              LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  
              if (convertView == null) {
                  convertView = inflater.inflate(R.layout.calendar_day, parent, false);
              }
  
              //get view
              TextView textView = (TextView) convertView.findViewById(R.id.calendar_day);
  
              //set data
              textView.setText(String.format("%d", calendarDays.get(position)));
              textView.setBackgroundColor(getResources().getColor(R.color.dateBackground));
  
              return convertView;
          }
      }
  }
  </code></pre>
  
  <p>MainActivity.java</p>
  
  <pre><code>import android.os.Bundle;
  import android.support.v7.app.AppCompatActivity;
  
  public class MainActivity extends AppCompatActivity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          MyCalendarView myCalendarView = (MyCalendarView) findViewById(R.id.my_calendar_view);
      }
  
  }
  </code></pre>