2011-07-07 6 views
0

J'utilise une disposition de table pour placer l'ImageView, j'ajoute 5 imageView dans une rangée, maintenant je veux en fonction de la largeur de l'écran tous les ImageViews ajustent automatiquement la distance entre eux, comment je peux le faire , ma TableLayoutas ci-dessous. .Mise en page automatique Réglage de l'ImageView

<TableLayout android:id="@+id/tableLayout1" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/transparent_background"> 
      <TableRow android:id="@+id/tableRow1" android:layout_height="wrap_content" android:stretchColumns="*" android:layout_width="fill_parent"> 
       <ImageView android:layout_height="wrap_content" android:id="@+id/imageView1" android:layout_width="wrap_content" android:src="@drawable/tea"></ImageView> 
       <ImageView android:layout_height="wrap_content" android:id="@+id/imageView2" android:layout_width="wrap_content" android:src="@drawable/bye" ></ImageView> 
       <ImageView android:layout_height="wrap_content" android:id="@+id/imageView3" android:layout_width="wrap_content" android:src="@drawable/brb" ></ImageView> 
       <ImageView android:layout_height="wrap_content" android:id="@+id/imageView4" android:layout_width="wrap_content" android:src="@drawable/pizza" ></ImageView> 
       <ImageView android:layout_height="wrap_content" android:id="@+id/imageView5" android:layout_width="wrap_content" android:src="@drawable/beer"></ImageView>   
      </TableRow>    
      <TableRow android:id="@+id/tableRow2" android:layout_width="wrap_content" android:layout_height="wrap_content"></TableRow> 
      <TableRow android:id="@+id/tableRow3" android:layout_width="wrap_content" android:layout_height="wrap_content"></TableRow> 
      <TableRow android:id="@+id/tableRow4" android:layout_width="wrap_content" android:layout_height="wrap_content"></TableRow> 

     </TableLayout> 

Répondre

0

salut d'abord u devoir obtenir la résolution de l'écran en fonction de la résolution u doivent modifier l'affichage de l'image size.use cette longueur de l'écran find code et hauteur

Display display = getWindowManager().getDefaultDisplay(); 
int width = display.getWidth(); 
int height = display.getHeight(); 

essayer ce lien, il vous aiderai u pour modifier dynamiquement l'affichage de l'image

set extended ImageView width and height programatically - android

+0

Salut merci pour le guide, tournez à droite maintenant essayer GridView il remplit automatiquement la place restante dans une mise en page avec ima geView. . . – aftab

Questions connexes