最も長い名前の直後に値を開始する必要がありますか? それとも、その最長の名前を表示できるようにするためですか? 私が提案する (そして同様の問題で行った) のは、LinearLayout ではなく、RelativeLayout を使用することです。
そこで 2 つの TextView を定義し、そのうちの 1 つは右側に重力があります。あなたのコードからわかることから、正しいフィールドは常に同じサイズですよね?したがって、それに応じて調整し、左側のスペースを自由に埋めてください。私のレイアウト例:
<?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="wrap_content"
android:background="@drawable/list_selector"
android:orientation="horizontal"
android:padding="3dip" >
<!-- Name-->
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:textColor="#040404"
android:typeface="sans"
android:textSize="20dip"
android:text="Name"
android:textStyle="bold"/>
<!-- Amount -->
<TextView
android:id="@+id/amount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:gravity="right"
android:layout_marginRight="5dip"
android:text="money"
android:textSize="20dip"
android:textColor="#FF8B1500"
android:textStyle="bold"
/>
</RelativeLayout>
右側の TextView は必要なだけのスペースを埋め、左側は名前用に残されています。
私がアイデアを与えるのを手伝ってくれたことを願っています!