Exemple Android LinearLayout
Sous Android,LinearLayout est une mise en page courante qui organise les «composants» dans l'ordre vertical ou horizontal, via l'attributorientation. De plus, le composant «weight» le plus élevé remplira l'espace restant enLinearLayout.
Dans ce tutoriel, nous vous montrons comment utiliserLinearLayout pour afficher 3 boutons dans l'ordre vertical et horizontal, et aussi comment fonctionne le «poids».
P.S This project is developed in Eclipse 3.7, and tested with Android 2.3.3.
1. Disposition linéaire - horizontale
Ouvrez le fichier «res/layout/main.xml», ajoutez 3 boutons dans lesLinearLayout, avec l'orientation «horizontal». Dans ce cas, le poids le plus élevé est «bouton3», il remplira donc l'espace restant dans la mise en page.
Fichier: res / layout / main.xml
Voir figure:

2. Disposition linéaire - verticale
Maintenant, changez l'orientationLinearLayout en «Vertical».
Fichier: res / layout / main.xml
Voir figure:

Télécharger le code source
Téléchargez-le -Android-LinearLayout-Example.zip (15 Ko)