IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Android Discussion :

disposition d'une activité


Sujet :

Android

  1. #1
    Membre à l'essai
    Homme Profil pro
    Étudiant
    Inscrit en
    Juillet 2016
    Messages
    19
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Canada

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Juillet 2016
    Messages : 19
    Points : 22
    Points
    22
    Par défaut disposition d'une activité
    Bonjour, J'aimerai divisé mon design en deux parties:
    - à gauche, je dispose mes boutons(5 boutons)
    - à droite, je veux remplacer les checkbox par 2 ListView pour y associer les items que l'utilisateur pourra selectionner d'une liste à l'autre.
    voir cod ci-dessous
    merci bien

    Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical" android:layout_width="match_parent"
        android:layout_height="match_parent">
     
     
        <GridLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:rowCount="6"
            android:columnCount="2">
     
            <TextView
                android:text="Complexité"
                android:layout_gravity="fill"
                android:textSize="25dp"
                android:layout_row="0"
                android:layout_column="0"
                android:id="@+id/txtComplexite"
                android:textAlignment="center" />
            <Button
                android:text="Très petit"
                android:layout_gravity="fill"
                android:layout_row="1"
                android:layout_column="0"
                android:id="@+id/btnTresPetit"
                android:textAlignment="center"/>
            <Button
                android:text="Petit"
                android:layout_gravity="fill"
                android:layout_row="2"
                android:layout_column="0"
                android:id="@+id/btnPetit"
                android:textAlignment="center"/>
            <Button
                android:text="Moyenne"
                android:layout_gravity="fill"
                android:layout_row="3"
                android:layout_column="0"
                android:id="@+id/btnMoyenne"
                android:textAlignment="center"/>
            <Button
                android:text="Gros"
                android:layout_gravity="fill"
                android:layout_row="4"
                android:layout_column="0"
                android:id="@+id/btnGros"
                android:textAlignment="center"/>
            <Button
                android:text="Tres gros"
                android:layout_row="5"
                android:layout_column="0"
                android:id="@+id/btnTresGros"
                android:textAlignment="center"/>
     
            <TextView
                android:text="Liste d'option"
                android:textSize="25dp"
                android:layout_row="1"
                android:layout_column="1"
                android:id="@+id/txtListeOption"
                android:textAlignment="center"/>
            <CheckBox
                android:text="Fruits"
                android:textSize="25dp"
                android:layout_gravity="fill"
                android:layout_row="2"
                android:layout_column="1"
                android:id="@+id/cbxFruits"/>
            <CheckBox
                android:text="Poissons"
                android:textSize="25dp"
                android:layout_gravity="fill"
                android:layout_row="3"
                android:layout_column="1"
                android:id="@+id/cbxPoissons"/>
            <CheckBox
                android:text="Legumes"
                android:textSize="25dp"
                android:layout_gravity="fill"
                android:layout_row="4"
                android:layout_column="1"
                android:id="@+id/cbxLegumes"/>
        </GridLayout>
     
    </LinearLayout>
    Fichiers attachés Fichiers attachés

  2. #2
    Membre confirmé
    Profil pro
    Inscrit en
    Juillet 2012
    Messages
    474
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2012
    Messages : 474
    Points : 586
    Points
    586
    Par défaut
    Bonjour,

    Déjà, englober un gridlayout par un linearlayout n'a aucun interêt.

    Il te suffit de faire un linearlayout avec orientation horiontal et tu mets chaque groupe dedans. Et utilise plutot un style général issu de style.xml pour tes boutons qui ont les mêmes caractéristiques
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal"
        android:baselineAligned="false">
     
     
        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:orientation="vertical">
     
            <TextView
                android:id="@+id/txtComplexite"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="fill"
                android:text="Complexité"
                android:textAlignment="center"
                android:textSize="25dp" />
     
            <Button
                android:id="@+id/btnTresPetit"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Très petit" />
     
            <Button
                android:id="@+id/btnPetit"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Petit" />
     
            <Button
                android:id="@+id/btnMoyenne"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Moyenne" />
     
            <Button
                android:id="@+id/btnGros"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Gros" />
     
            <Button
                android:id="@+id/btnTresGros"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Tres gros"
                android:textAlignment="center" />
     
        </LinearLayout>
     
        <ListView
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1" />
     
        <ListView
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1" />
     
    </LinearLayout>

  3. #3
    Membre à l'essai
    Homme Profil pro
    Étudiant
    Inscrit en
    Juillet 2016
    Messages
    19
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Canada

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Juillet 2016
    Messages : 19
    Points : 22
    Points
    22
    Par défaut
    J'aimerai modifier l'interface afin d'obtenir celle qui est joint au fichier. (voir fichier joint.)
    merci
    Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal"
        android:baselineAligned="false">
     
     
        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:orientation="vertical">
     
            <TextView
                android:id="@+id/txtGrandeur"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="fill"
                android:text="Grandeur"
                android:textAlignment="center"
                android:textSize="25dp" />
     
            <Button
                android:id="@+id/btnTresPetit"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Très petit" />
     
            <Button
                android:id="@+id/btnPetit"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Petit" />
     
            <Button
                android:id="@+id/btnMoyenne"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Moyenne" />
     
            <Button
                android:id="@+id/btnGros"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Gros" />
     
            <Button
                android:id="@+id/btnTresGros"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Tres gros"
                android:textAlignment="center" />
     
        </LinearLayout>
     
        <ListView
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1" />
     
        <ListView
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1" />
     
    </LinearLayout>
    Fichiers attachés Fichiers attachés

  4. #4
    Membre extrêmement actif
    Profil pro
    Développeur
    Inscrit en
    Mars 2012
    Messages
    1 969
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations professionnelles :
    Activité : Développeur
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Mars 2012
    Messages : 1 969
    Points : 3 375
    Points
    3 375
    Par défaut
    J'ai regardé ton schema: avec des linearLayout imbriqués tu peux le faire, voir même avec un GridLayout au milieu.
    Si la réponse vous a aidé, pensez à cliquer sur +1

  5. #5
    Membre à l'essai
    Homme Profil pro
    Étudiant
    Inscrit en
    Juillet 2016
    Messages
    19
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Canada

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Juillet 2016
    Messages : 19
    Points : 22
    Points
    22
    Par défaut imbrication des LinearLayout
    j'ai essayé les imbrications des LinearLayout et les GridLayout pour la disposition des elements sur ma vue,
    mais je suis toujours bloqué avec la disposition des 3 boutons qui doivent
    etre situé en bas.
    merci de bien vouloir m'eclaicir.

  6. #6
    Membre confirmé
    Profil pro
    Inscrit en
    Juillet 2012
    Messages
    474
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2012
    Messages : 474
    Points : 586
    Points
    586
    Par défaut
    Apparemment, tu n'as pas bien compris l'intérêt des LinearLayout et de l'attribut android:orientation.

    Comme décrit en tout début de sa référence
    A Layout that arranges its children in a single column or a single row. The direction of the row can be set by calling setOrientation().
    Ce qui veut dire que ca sert à empiler les vues les unes sur les autres ou à les disposer côte à côte.

    Dans ton cas, en utilisant une orientation verticale, tu peux empiler les boutons les uns par dessous les autres.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
     
     
         <Button
                android:id="@+id/bouton1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />
     
            <Button
                android:id="@+id/bouton2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"/>
    
    <LinearLayout >
    
    LINEARLAYOUT DE LA REPONSE PRECEDENTE
    
    </LinearLayout >
     
    
    <Button
                android:id="@+id/bouton3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />
     
    <Button
                android:id="@+id/bouton4"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"/>
    <Button
                android:id="@+id/bouton5"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />
     
    </LinearLayout>

  7. #7
    Membre extrêmement actif
    Profil pro
    Développeur
    Inscrit en
    Mars 2012
    Messages
    1 969
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations professionnelles :
    Activité : Développeur
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Mars 2012
    Messages : 1 969
    Points : 3 375
    Points
    3 375
    Par défaut
    en fait les linearLayout sont des "containers".
    Tu donnes l'orientation de l'objet (horizontal ou vertical) et tu empiles.
    Ces containers se remplissent de gauche vers la droite et de haut vers le bas.
    Quand tu dois changer de sens, tu ajoutes (par exemple) un autre linearLayout.
    Si la réponse vous a aidé, pensez à cliquer sur +1

  8. #8
    Modérateur
    Avatar de MasterMbg
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Octobre 2011
    Messages
    719
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Congo-Kinshasa

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Octobre 2011
    Messages : 719
    Points : 1 493
    Points
    1 493
    Par défaut
    Salut,

    Il faut justement jouer avec les attributs layout_weight, layout_height, layout_width... et les linearLayout ou RelativeLayout selon que tu te sens à l'aise avec l'un ou l'autre. Dans le code ci dessous, j'ai utilisé des LinearLayout

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
     
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
     
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_margin="5dp"
            android:layout_weight="5"
            android:orientation="horizontal">
     
            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:orientation="vertical">
     
                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:text="Mon TextView" />
     
                <Button
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_weight="1"
                    android:text="Bouton 1" />
     
                <Button
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_weight="1"
                    android:text="Bouton 2" />
     
                <Button
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_weight="1"
                    android:text="Bouton 3" />
     
                <Button
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_weight="1"
                    android:text="Bouton 4" />
     
                <Button
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_weight="1"
                    android:text="Bouton 5" />
            </LinearLayout>
     
            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:orientation="horizontal">
                <ListView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"></ListView>
            </LinearLayout>
     
            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:orientation="horizontal">
                <ListView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"></ListView>
            </LinearLayout>
     
        </LinearLayout>
     
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_margin="5dp"
            android:layout_weight="2"
            android:orientation="vertical">
     
            <Button
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:text="Bouton 6" />
     
            <Button
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:text="Bouton 7" />
     
            <Button
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:text="Bouton 8" />
        </LinearLayout>
    </LinearLayout>
    Je pense que c'est approximativement ce que tu cherches...

    Christian Djo,
    Plus tu apprends sérieusement, plus tu te rapproches d'un savoir noble. Une chose est certaine, les difficultés ne s'écarteront de ton chemin...

    Tu es nouveau dans le développement Android, la page des COURS est là pour te faciliter la vie
    Tu peux trouver la réponse à ta question dans la FAQ
    Retrouvez mon tutoriel sur la consommation des services web SOAP
    Pense à voter positivement en appuyant sur en bas à droite de la réponse qui t'a donné une piste de solution.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [MCD]gamme opératoire d'une activité
    Par Mike888 dans le forum Schéma
    Réponses: 15
    Dernier message: 20/11/2007, 10h58
  2. [DOM] Barre d'activité témoignant d'une activité incessante
    Par *s0ma* dans le forum Général JavaScript
    Réponses: 6
    Dernier message: 03/07/2007, 22h43
  3. Simuler une activité pour empêcher une déconnection
    Par docjfnoel dans le forum VB 6 et antérieur
    Réponses: 6
    Dernier message: 28/05/2007, 11h05
  4. Réponses: 2
    Dernier message: 29/04/2007, 16h35
  5. [C#][VS2003] Disposition dans une ToolBar
    Par shinkyo dans le forum Windows Forms
    Réponses: 2
    Dernier message: 04/05/2006, 18h19

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo