Aller au contenu
View in the app

A better way to browse. Learn more.

Forum de Frandroid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

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

Featured Replies

Posté(e)

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

Modifié par bitoons

Posté(e)

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.

Posté(e)
  • Auteur

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é.

Posté(e)

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.

Posté(e)
  • Auteur

Merci !!! c'est exactement ce que je voulais !! merci beaucoup

Archivé

Ce sujet est désormais archivé et ne peut plus recevoir de nouvelles réponses.

Account

Navigation

Rechercher

Rechercher

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.