Jump to content

[résolu] Comment faire tenir une listview entre deux linearlayout


bitoons

Recommended Posts

Bonjour, depuis peu dans la programmation android je n'arrive pas à faire tenir un liste entre deux linearlayout ou autre pour pouvoir mettre des informations au dessus et des boutons en bas, tout ceci avec la listView entre les deux. A chaque fois la liste descend plus bas que l'écran et je perds les boutons ? voici mon code XML:

<?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"
   >
<LinearLayout 
android:layout_width="fill_parent" 
android:id="@+id/lstArticles" 
android:layout_height="wrap_content">
	<TableLayout
	android:layout_width="fill_parent"
	android:layout_height="match_parent"
	android:stretchColumns="1">
		<TableRow>
			<LinearLayout 
			android:id="@+id/linearLayout3" 
			android:layout_height="match_parent"
			android:layout_width="fill_parent"
			android:background="@drawable/bgselectioncom"
			android:layout_span="3">
			</LinearLayout>
		</TableRow>
		<TableRow>
			<LinearLayout 
				  xmlns:android="http://schemas.android.com/apk/res/android" 
				  android:orientation="vertical" 
				  android:layout_width="match_parent" 
				  android:layout_height="fill_parent"
				  android:background="#000000"
				  android:layout_span="3"
				  > 
				  <ListView android:id="@+id/zoneCommercial"
				    android:orientation="vertical" 
				    android:layout_width="fill_parent" 
				    android:layout_height="fill_parent"> 
				  </ListView>
			  </LinearLayout>
		</TableRow>
		<TableRow>
			<LinearLayout 
			android:id="@+id/linearLayout3" 
			android:layout_height="match_parent"
			android:layout_width="fill_parent"
			android:padding="2px"
			android:background="@drawable/bgselectioncom"
			android:layout_span="3">
			</LinearLayout>
		</TableRow>
	</TableLayout>
</LinearLayout>
</LinearLayout>

en gros je voudrais comme dans l'application prixing mais sans les tabView :

post-16618-0-97089300-1305283999_thumb.j

Merci beaucoup

Link to comment
Share on other sites

Oula, tu as des layout de trop/inutile !

Va au plus simple :

<?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"
   >
<LinearLayout 
android:id="@+id/linearLayout3" 
android:layout_height="match_parent"
android:layout_width="fill_parent"
android:background="@drawable/bgselectioncom">
</LinearLayout>
<ListView android:id="@+id/zoneCommercial"
android:orientation="vertical" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"> 
</ListView>
<LinearLayout 
android:id="@+id/linearLayout3" 
android:layout_height="match_parent"
android:layout_width="fill_parent"
android:padding="2px"
android:background="@drawable/bgselectioncom">
</LinearLayout>
</LinearLayout>

Je n'ai pas testé mais je pense que ça fonctionne. Personnellement j'aurais utilisé un RelativeLayout (j'utilise pratiquement que ça) avec un layout aligné un haut, un en bas et la listView entre les deux.

Link to comment
Share on other sites

non ça ne marche pas quand j'ai que deux éléments dans ma liste le LineaLayout du bas est atacher au bas de la liste et non au bas de l'écran et quand j'ai beaucoup d’élément le linearLayout disparais. en gros je voudrais que la liste se déroule entre deux block ?

oui il y a beaucoup de layout inutile je suis un peu perdu ! désolé.

Link to comment
Share on other sites

Essayez le code suivant :

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:orientation="vertical"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   >

     <LinearLayout
       android:orientation="horizontal"
       android:layout_width="fill_parent"
       android:layout_height="wrap_content"
       >
		        <Button android:id="@+id/button1"
		            android:layout_width="wrap_content"
		            android:layout_height="wrap_content"
		            android:layout_weight="1"
		            android:layout_gravity="bottom"
		            android:text="bouton 1 "
		        />
		        <Button android:id="@+id/button2"
		            android:layout_width="wrap_content"
		            android:layout_height="wrap_content"
		            android:layout_weight="1"
		            android:layout_gravity="bottom"
		            android:text="bouton 2"
		        />
       </LinearLayout>
   <ListView android:id="@+id/listView"
       android:layout_width="fill_parent"
       android:layout_height="fill_parent"
       android:transcriptMode="alwaysScroll"
       android:layout_weight="1"
   />
   <LinearLayout
       android:orientation="vertical"
       android:layout_width="fill_parent"
       android:layout_height="wrap_content"
       >
       <TextView android:id="@+id/textView"
           android:layout_width="fill_parent"
           android:layout_height="wrap_content"
           android:layout_weight="1"
           android:layout_gravity="bottom"
           android:text="mon texte view :"
       />
       <LinearLayout
       android:orientation="horizontal"
       android:layout_width="fill_parent"
       android:layout_height="wrap_content"
       >
		        <Button android:id="@+id/button3"
		            android:layout_width="wrap_content"
		            android:layout_height="wrap_content"
		            android:layout_weight="1"
		            android:layout_gravity="bottom"
		            android:text="bouton 3"
		        />
		        <Button android:id="@+id/button4"
		            android:layout_width="wrap_content"
		            android:layout_height="wrap_content"
		            android:layout_weight="1"
		            android:layout_gravity="bottom"
		            android:text="bouton 4"
		        />
       </LinearLayout>
       <Button android:id="@+id/bouton5"
           android:layout_width="fill_parent"
           android:layout_height="wrap_content"
           android:layout_weight="1"
           android:layout_gravity="bottom"
           android:text="bouton 5"
       />
   </LinearLayout>
</LinearLayout>

Il s'agit d'une adaptation rapide d'une de mes sources, j'imagine qu'elle devrait convenir à votre demande.

Simon Daget.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...