I have a table row setup using relative layout. It has 2 TextView both of which I want to have equal spacing and left aligned text. See current setup below. This has one textview aligned left and another right. When I change to align both to left content overlaps.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout02"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dip">
<TextView
android:id="@+id/displayLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:layout_toRightOf="@+id/row_image"
android:text="adasd"
android:textSize="18sp" />
<TextView
android:id="@+id/displayValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="20dp"
android:text="adasd"
android:textSize="18sp"/>
</RelativeLayout>
Any suggestions. Thanks in advance for the help.
It seems like a job for weighted LinearLayout – display two equaly-sized text views:
Then in emulator it will looks like:

Note the
layout_weightattribute in both text views and zerolayout_width. Basically it means that the views will get additional amount of free space proportional to specified weight. So for equivalent weights these views will be of identical width.See layout guide on developer.android.com for further reference.