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

Composants graphiques Android Discussion :

Séparateurs entre 3 TextViews (dont height=wrap_content))


Sujet :

Composants graphiques Android

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Homme Profil pro
    Inscrit en
    Octobre 2012
    Messages
    172
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Octobre 2012
    Messages : 172
    Par défaut Séparateurs entre 3 TextViews (dont height=wrap_content))
    Bonjour à tous,

    n'étant pas sur que le titre soit assez explicite (toutes mes excuses), voici mon probleme :

    - 1 LinearLayout contenant 3 textviews tels que:
    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
    <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content" 
                android:weightsum="3">
    
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:text="trucmuche1" />
                 
                 <View
                      android:layout_width="0.5dp"
                      android:layout_height="???"
                      android:background="@android:color/darker_gray"
                   />            
    
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:text="Truc2" />
    
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:text="Truc3" />
            </LinearLayout>
    - Je cherche à mettre des traits séparateurs entre chaque TextViews par le biais d'une View (en bleu dans l'extrait de code)

    Soucis :
    - J'aimerais que le trait fasse toute la hauteur du LinearLayout mais si je mets :

    android:layout_height="match_parent"

    Le Layout prend toute la hauteur de l'ecran.

    Comment faire en sorte que le trait séparateur occupe toute la hauteur du layout mais SANS en modifier la hauteur (en wrap_content pour rappel)?

    un Grand merci d'avance pour vos reponses

  2. #2
    Membre émérite
    Profil pro
    Inscrit en
    Janvier 2011
    Messages
    757
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2011
    Messages : 757
    Par défaut
    Citation Envoyé par Gob59 Voir le message
    Le Layout prend toute la hauteur de l'ecran.
    Ben normalement ça devrait fonctionner correctement avec l'attribut match_parent.
    De plus, si tu spécifie un poids à une vue, il est inutile de lui indiquer sa taille :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
               <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:text="Truc2" />
    //est équivalent à (dans le cas d'un linearlayout horizontal)
               <TextView
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:text="Truc2" />
    Eclipse doit normalement t'avertir de ce "soucis".

    Pour ce qui est des séparateurs (dividers), il existe des attributs pour le linearLayout qui te permettent de configurer ce comportement :
    https://developer.android.com/refere...DIVIDER_MIDDLE et https://developer.android.com/refere...ndroid:divider

  3. #3
    Membre actif
    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    46
    Détails du profil
    Informations personnelles :
    Âge : 40
    Localisation : France

    Informations forums :
    Inscription : Janvier 2007
    Messages : 46
    Par défaut
    Si t'as envie de garder ton approche, voila une solution pour ton problème de calage.

    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
     
    <RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">
     
            <TextView
                android:id="@+id/text1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="trucmuche1" />
     
            <View
                android:id="@+id/separator1"
                android:layout_width="0.5dp"
                android:layout_height="fill_parent"
                android:layout_toRightOf="@+id/text1"
                android:layout_alignBottom="@+id/text1"
                android:background="@android:color/darker_gray"/>
     
            <TextView
                android:id="@+id/text2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@+id/separator1"
                android:text="Truc2" />
     
            <View
                android:id="@+id/separator2"
                android:layout_width="0.5dp"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@+id/text2"
                android:layout_alignBottom="@+id/text2"
                android:background="@android:color/darker_gray"/>
     
             <TextView
                android:id="@+id/text3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@+id/separator2"
                android:text="Truc3" />
     
        </RelativeLayout>

  4. #4
    Membre confirmé
    Homme Profil pro
    Inscrit en
    Octobre 2012
    Messages
    172
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Octobre 2012
    Messages : 172
    Par défaut
    Merci à vous

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

Discussions similaires

  1. Séparateur entre deux nombres
    Par Abime dans le forum Langage SQL
    Réponses: 3
    Dernier message: 20/04/2009, 07h46
  2. Réponses: 2
    Dernier message: 10/03/2009, 10h32
  3. Réponses: 29
    Dernier message: 09/08/2007, 15h39
  4. Problème d'accents entre 2 scripts (dont 1 jpGraph)
    Par nicobest dans le forum Langage
    Réponses: 2
    Dernier message: 25/05/2007, 09h41

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