views:

78

answers:

2

alt text

How can I prevent this overlapping from occurring without reducing the font size? Here is my XML:

<?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">   
    <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:paddingTop="2dip"
        android:paddingLeft="5dip"
        android:paddingBottom="1dip"/>
    <TextView
        android:id="@+id/changeText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:gravity="right"     
        android:textSize="18sp"
        android:paddingTop="9dip"
        android:paddingRight="5dip"
        android:paddingBottom="1dip" android:text="13.07(+43.08%)" android:paddingLeft="5dip"/>  
    <ImageView android:layout_toLeftOf="@+id/changeText" android:layout_width="wrap_content" android:layout_height="fill_parent" android:id="@+id/verticalDivider" android:background="@drawable/stocks_selected_gradient"></ImageView><TextView
        android:id="@+id/priceText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toLeftOf="@+id/changeText"
        android:gravity="right"     
        android:textStyle="bold"
        android:textSize="24sp"
        android:textColor="#4871A8"
        android:paddingTop="2dip"
        android:paddingBottom="1dip"
        android:paddingRight="25dip" android:text="15000"/>  

</RelativeLayout>
A: 

Encapsulate the TextViews in a LinearLayout (orientation = horizontal). For the individual TVs specify android:layout_weight (remember weights work differently when using android:layout_width=fill_parent/wrap_content)

Sameer Segal
+1  A: 

In your second TextView, change android:layout_alignParentRight="true" to

android:layout_toRightOf="@+id/nameText"
Charlie Sheen
that causes my UI to mess up, and everything overlaps. I need that textview specifically to be right-aligned.
Sheehan Alam
Your text is too big then, reduce the paddingRight is your solution.
Charlie Sheen
@Sheehan Alam, Charlie Sheen is right, you have too much text in a little area.
Julian Assange