Par exemple, j'ai un ListView, et pour chaque ligne de données est comme ceComment aligner le texte dans la vue texte Android
Name: Mr.ABC
Address: Flat A, 25/F, Block 2,
USA....
Gender: Male
Hobbies: Football, Baseball.....
.....
Et ce qui précède est la façon dont il regarde actuellement aime, j'utilise 4 regardez le texte pour représenter chaque donnée
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="9"
android:orientation="vertical"
android:paddingLeft="5dp" >
<TextView
android:id="@+id/resultName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp" />
<TextView
android:id="@+id/resultLang"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp" />
<TextView
android:id="@+id/resultType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp" />
<TextView
android:id="@+id/resultOrg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp" />
<TextView
android:id="@+id/resultYear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp" />
</LinearLayout>
le problème est comment puis-je aligner le texte comme celui-ci?
Name: Mr.ABC
Address: Flat A, 25/F, Block 2,
USA....
Gender: Male
Hobbies: Football, Baseball.....
.....
Merci pour aider
Mise à jour
<TableLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="9"
android:paddingLeft="5dp"
android:shrinkColumns="*"
android:stretchColumns="*" >
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_weight="1"
android:text="@string/search_name"
android:textSize="16sp" />
<TextView
android:id="@+id/resultName"
android:layout_weight="1"
android:textSize="16sp" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_weight="1"
android:text="@string/search_lang"
android:textSize="16sp" />
<TextView
android:id="@+id/resultLang"
android:layout_weight="1"
android:textSize="16sp" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_weight="1"
android:text="@string/search_type"
android:textSize="16sp" />
<TextView
android:id="@+id/resultType"
android:layout_weight="1"
android:textSize="16sp" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_weight="1"
android:text="@string/search_org"
android:textSize="16sp" />
<TextView
android:id="@+id/resultOrg"
android:layout_weight="1"
android:textSize="16sp" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_weight="1"
android:text="@string/search_yr"
android:textSize="16sp" />
<TextView
android:id="@+id/resultYear"
android:layout_weight="1"
android:textSize="16sp" />
</TableRow>
</TableLayout>
Le code ci-dessus est mis à jour, mais le problème est, car il est listview et je trouve que la largeur du côté gauche n'est pas égal. C'est quelque chose comme par exemple
Name: Mr.ABC
Address: Flat A, 25/F, Block 2,
USA....
Gender: Male
Hobbies: Football, Baseball.....
.....
Name: Mr.Asfsafasfdfsd
Address: Flat V, 25/F, Block 2,
USA....
Gender: Female
Hobbies: Basketball.....
.....
Name: Mr.WQWRWEE
Address: Flat V, 25/F, Block 2,
USA....
Gender: Male
Hobbies: Baseball.....
.....
Vous pouvez utiliser 8 textviews. Je ne pense pas que vous pourriez obtenir l'alignement désiré en utilisant seulement 4 textviews – novic3
oui et en utilisant la mise en page de poids, mais comment puis-je définir le poids? merci – user782104
par exemple. 1 pour le nom: et 9 pour le M. ABC? mais que faire si un écran d'appareil est trop petit pour montrer le nom? – user782104