Я хочу, чтобы отобразить текст в ListView строки со следующим выравниванием:Как выровнять текст в макете в андроида
Mike 10pt $1,233,500
Mike2 200pt $1,2,500
Holly 10pt $4500
Но когда я попробовал, я получил это вместо:
Mike 10pt $1,233,500
Mike2 200pt $12,500
Holly 10pt $4500
Мой файл макета ниже. Что я делаю не так?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center"
android:background="@drawable/dl005_textfield_selected"
android:paddingBottom="5dp" >
<TextView
android:id="@+id/Name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="Mike"
android:layout_weight="1"
android:textColor="#888888" />
<TextView
android:id="@+id/score"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:gravity="right"
android:text="10pt"
android:textColor="#3498db" />
<TextView
android:id="@+id/myid"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:text="$1,233,500"
android:textStyle="bold"
android:textSize="18sp"
android:layout_weight="1"
android:gravity="right"
android:textColor="#3498db" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
</LinearLayout>
</LinearLayout>
Вы считали использование ['TableLayout'] (http://developer.android.com/reference/android/widget/TableLayout.html)? Похоже, это было бы идеально для этого макета. Из документов: «Макет, который упорядочивает его дочерние элементы в строки и столбцы». Вы можете установить выравнивание текста ячейки влево/вправо по мере необходимости. – stkent
Использование «TableLayout» - это рекомендуемый способ и для вашего линейного выхода, когда вы используете свойство веса с горизонтальным расположением, тогда его 'ширина' должна быть' 0dp'. – Piyush