android center textview in layout
<p>I have a listview with custom rows. In the row there are these items:</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:layout_width="fill_parent"
  android:layout_height="wrap_content"&gt;
  &lt;ImageView
    android:id="@+id/imageView1"
    android:layout_width="10dp"
    android:layout_height="fill_parent"
    android:focusable="false"
    android:scaleType="fitXY"&gt;
   &lt;/ImageView&gt;"

  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/textsll"
    android:layout_gravity="center_vertical"
    android:gravity="center_vertical"
    android:layout_marginLeft="5dp"&gt;          
  &lt;TextView android:id="@+id/textView1" 
    android:layout_width="240dp" 
    android:layout_height="wrap_content"
    android:textColor="#000000"
    android:layout_alignParentBottom="true" 
    android:layout_alignParentTop="true"
    android:layout_centerVertical="true"
    android:maxLines="1"
    android:ellipsize="end"&gt;"
  &lt;/TextView&gt;
  &lt;TextView android:id="@+id/textView2" 
    android:layout_width="240dp" 
    android:layout_height="wrap_content"
    android:textColor="#000000"
    android:layout_alignParentBottom="true"
    android:layout_below="@+id/textView1"
    android:maxLines="1"
    android:ellipsize="end"&gt;
  &lt;/TextView&gt;
  &lt;/RelativeLayout&gt;

  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/textsll2"
    android:layout_gravity="center_vertical|right"
    android:layout_marginLeft="10dp"&gt;"
  &lt;TextView android:id="@+id/textView3" 
    android:layout_width="40dp" 
    android:layout_height="wrap_content"
    android:textColor="#000000"
    android:paddingBottom="5dp"
    android:maxLines="1"
    android:ellipsize="end"
    android:gravity="center_vertical"
    android:background="#87EB81"&gt;
  &lt;/TextView&gt;
  &lt;/LinearLayout&gt;

&lt;/LinearLayout&gt;
</code></pre>

<p>If both textviews has some content, they are centered vertically in the row (almost).</p>

<p>But if the lower textview is empty, I call:</p>

<pre><code>            holder.textView2.setVisibility(View.INVISIBLE);
            holder.textView.setGravity(Gravity.CENTER_VERTICAL);
</code></pre>

<p>Still, the upper textview gets into the top of the row. Why?</p>

<p><img src="http://i.stack.imgur.com/IRzLC.png" alt="enter image description here"></p>

<p>If I set it to View.GONE, I get this, but I dont want the height of the row to change:</p>

<p><img src="http://i.stack.imgur.com/MhZse.png" alt="enter image description here"></p>
