You should wrap text views in RelativeLayout
. Specify android:layout_width="wrap_content"
for both, and android:layout_alignParentLeft="true"
and android:layout_alignParentRight="true"
for the left and right TextViews respectively. Set android:gravity="left"
and android:gravity="right"
respectively, as well
But in this case long text may overlap
another option is to use layout_weight
:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="left"
android:text="some text"/>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="right"
android:text="text"/>
</LinearLayout>