views:

25

answers:

1

I have the following layout. This defines a row in my ListView. I noticed that the text is not centered in the row. There seems to be extra bottom padding. How can I make the text appear in the center, vertically, so there is no padding?

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" android:background="@drawable/stocks_gradient">   
    <TextView
        android:id="@+id/nameText"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:text="Symbol" android:textStyle="bold" android:textSize="24sp" android:layout_width="100dp" android:textColor="#4871A8" android:paddingLeft="5dp"/>
    <TextView
        android:id="@+id/priceText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@+id/nameText"
        android:gravity="right"     
        android:text="100" android:textStyle="bold" android:textSize="24sp" android:textColor="#4871A8"/>  
    <TextView
        android:id="@+id/changeText"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@+id/priceText"
        android:gravity="right"     
        android:textSize="18sp" android:text="3.07(+1.08%)" android:padding="7dip"/>  
</RelativeLayout>
A: 

Did you try setting the layout_gravity to center_vertical?

Also, you may have a reason for doing so, but the layout you show would be much simpler as a horizontal LinearLayout. There is no need for a RelativeLayout here.

Mayra