2011-10-08 5 views
1

Je veux implémenter ce type de vue dans mon application. . .Comment définir cette tableLayout dans android?

data1 hello hi 
data2 hello2 hi 
data3 hi  Hello 

Je veux savoir, lequel est le meilleur moyen de le régler? TableLayout oranyother linearLayout.RelativeLayout ??? Je veux également que le code xml définisse cette disposition. . Merci.

Répondre

4

Essayez ceci,

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <TableLayout android:layout_width="fill_parent" 
     android:layout_height="wrap_content"> 

     <TableRow android:weightSum="3"> 
      <TextView android:layout_weight="1" android:layout_width="wrap_content" 
       android:layout_height="wrap_content" android:text="hello" /> 
      <TextView android:layout_weight="1" android:layout_width="wrap_content" 
       android:layout_height="wrap_content" android:text="hello" /> 
      <TextView android:layout_weight="1" android:layout_width="wrap_content" 
       android:layout_height="wrap_content" android:text="hello" /> 
     </TableRow> 

     <TableRow android:weightSum="3"> 
      <TextView android:layout_weight="1" android:layout_width="wrap_content" 
       android:layout_height="wrap_content" android:text="hello" /> 
      <TextView android:layout_weight="1" android:layout_width="wrap_content" 
       android:layout_height="wrap_content" android:text="hello" /> 
      <TextView android:layout_weight="1" android:layout_width="wrap_content" 
       android:layout_height="wrap_content" android:text="hello" /> 
     </TableRow> 

     <TableRow android:weightSum="3"> 
      <TextView android:layout_weight="1" android:layout_width="wrap_content" 
       android:layout_height="wrap_content" android:text="hello" /> 
      <TextView android:layout_weight="1" android:layout_width="wrap_content" 
       android:layout_height="wrap_content" android:text="hello" /> 
      <TextView android:layout_weight="1" android:layout_width="wrap_content" 
       android:layout_height="wrap_content" android:text="hello" /> 
     </TableRow> 
    </TableLayout> 
</LinearLayout> 
+1

Ok Nice. Ça marche. Maintenant, si je veux donner le plus de taille à la deuxième colonne alors devrais-je donner le weightSum à 4 et le deuxième textview au poids 2 à droite ??? –

+0

oui, exactement, je pense que vous avez compris comment cela fonctionne. :) –

+0

Oui je l'ai eu. Merci. –

2

TableLayout est préférable est votre cas. Exemple: http://www.tutorialforandroid.com/2008/12/simple-tablelayout-in-android.html

@note: ne soyez pas si paresseux avec Google!

+0

Cher i ont une recherche sur Google pour cela. Mais je veux une telle disposition qui correspond à la largeur de l'écran. Et la mise en page devrait être bonne en apparence. C'est pourquoi j'ai posé une question. Je n'obtiens toujours pas la réponse correcte. Comme je veux la mise en page qui correspond à l'écran de l'appareil. –

+0

définir 'fill_parent' pour remplir la mise en page à l'écran entier –

Questions connexes