title: Getting child view to match_parent in Android
body: <p>I have a simple linear layout which I'm inflating in an adapter:</p>
  
  <pre><code>    @Override
      public View getView(final int position, View convertView, final ViewGroup parent) {
  
          if (convertView == null) {
              convertView = inflater.inflate(R.layout.category_listview_row, parent, false);
          } else {
              ((LinearLayout)convertView).removeAllViews();
          }
  
          if (LAYOUT_TYPES.GRID.equals(layoutType)) {
              convertView = CategoryFragment.getViewForGridLayout(context, displayArray, position, convertView, listener);
          } else {
              convertView = CategoryFragment.getViewForListLayout(context, displayArray, position, convertView, listener);
          }
  
          return convertView;
      }
  </code></pre>
  
  <p>Here, <code>category_listview_row</code> is the following:</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="horizontal"
      android:gravity="top"
      android:layout_width="match_parent"
      android:layout_height="wrap_content" /&gt;
  </code></pre>
  
  <p>The <code>getViewForGridLayout</code> method programmatically creates one or more views and adds them to <code>convertView</code>.</p>
  
  <p>I would like all the child views to match this parent view in height, however I can't get this to work. This is the outer linear layout of the child views that are added programmatically:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:id="@+id/base_listview_style_one_layout"
      android:orientation="horizontal"
      android:padding="@dimen/node_default_spacing"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:background="#5ab9c6"&gt;
  </code></pre>
  
  <p>This layout has subviews which are removed according to the actual data to be displayed, so some will be longer than others. However I want them all to be the height of the parent so it doesn't look weird.</p>
  
  <p>This is a screenshot of what I'm seeing:</p>
  
  <ul>
  <li>The first row is ok since both items have a title and a subtext</li>
  <li>On the second row, the second item doesn't have a subtext so that view is smaller. However, I'd like it to take the full height of the row so all items in a single row will have the same height.</li>
  </ul>
  
  <p><a href="https://i.stack.imgur.com/UVgeH.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UVgeH.jpg" alt="enter image description here"></a></p>
  
  <p>Any tips? Thanks!</p>