title: Centering ListView's empty view in parent
body: <p>I have a <code>ListView</code> with an empty view set as a view I create programmatically. I'd like to have it centered both horizontally and vertically. I found this code while searching how to do that on google.:  </p>
  
  <pre><code>TextView myTv = new TextView(getActivity());
  myTv.setText("No results");
  RelativeLayout.LayoutParams param = new RelativeLayout.LayoutParams(
          LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
  param.addRule(RelativeLayout.CENTER_IN_PARENT, 0);
  myTv.setLayoutParams(param);
  myTv.setVisibility(View.GONE);
  ((RelativeLayout) mScheduleListView.getParent()).addView(myTv, 0);
  
  mScheduleListView.setEmptyView(myTv);
  </code></pre>
  
  <p>The XML layout for the fragment holding the ListView above looks like this:  </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context=".ScheduleFragment" &gt;
  
      &lt;ListView android:id="@+id/mScheduleListView"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:orientation="vertical"
          android:padding="10dp"
          android:divider="@null"
          android:dividerHeight="10.0sp" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>The layout shows, but not centered. I have no idea why it doesn't work. I tried messing with the <code>LayoutParams</code> and change them to <code>MATCH_PARENT</code> but apparently that wasn't the problem.<br>
  If so what could be the problem and how to solve it?  </p>