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 :

RelativeLayout avec ScrollView


Sujet :

Android

  1. #1
    Membre du Club
    Profil pro
    Inscrit en
    Février 2003
    Messages
    49
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2003
    Messages : 49
    Points : 49
    Points
    49
    Par défaut RelativeLayout avec ScrollView
    Bonjour,

    J'essaie de créer un RelativeLayout avec un scroll horizontal, mais à l’exécution tout "se marche dessus" ....

    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
     
    <?xml version="1.0" encoding="utf-8"?>
    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:fillViewport="true"> <!--IMPORTANT otherwise backgrnd img. will not fill the whole screen -->
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">
            android:layout_height="250dp"
     
            <TextView
                android:id="@+id/textViewRejet"
                android:layout_width="match_parent"
                android:layout_height="75dp"
                android:text="Liste des numéros bloqués : "
                android:textAppearance="?android:attr/textAppearanceLarge" />
     
            <EditText
                android:id="@+id/edittextViewRejet"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="top"
                android:inputType="textMultiLine" />
     
            <Button
                android:id="@+id/buttonSMS"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:onClick="updatesms"
                android:text="Valider pour bloquer les SMS" />
     
            <Button
                android:id="@+id/buttonTEL"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:onClick="updatetel"
                android:text="Valider pour bloquer les Appels" />
     
            <TextView
                android:id="@+id/textViewSMS"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Texte du SMS de rejet : "
                android:textAppearance="?android:attr/textAppearanceLarge" />
     
     
            <EditText
                android:id="@+id/editTextSMS"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:gravity="top"
                android:inputType="textMultiLine" />
     
            <ListView
                android:id="@+id/list"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"></ListView>
     
        </RelativeLayout>
     
    </ScrollView>

  2. #2
    Membre à l'essai
    Homme Profil pro
    Étudiant
    Inscrit en
    Mars 2017
    Messages
    18
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 28
    Localisation : France, Pyrénées Atlantiques (Aquitaine)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mars 2017
    Messages : 18
    Points : 16
    Points
    16
    Par défaut
    Salut!
    Lorsque tu utilise un RelativeLayout, il faut placer tes vues les unes par rapport aux autres. Tu peux le faire en utilisant les attributs:

    android:layout_below (pour aligner le plafond d'une vue sous le plancher d'une autre)
    android:layout_above (pour aligner le plancher d'une vue sur le plafond d'une autre)
    android:layout_toRightOf (pour aligner le bord gauche d'une vue au bord droit d'une autre)
    android:layout_toLeftOf (pour aligner le bord droit d'une vue au bord gauche d'une autre)
    Sinon tu peux utiliser un LinearLayout qui te placera tes éléments à la suite l'un en dessous de l'autre en précisant android:orientation="vertical".

  3. #3
    Membre du Club
    Profil pro
    Inscrit en
    Février 2003
    Messages
    49
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2003
    Messages : 49
    Points : 49
    Points
    49
    Par défaut
    Super !
    Merci beaucoup, çà marche parfaitement pour que les objets soient bien en dessous les uns des autres.
    Par contre, le ScrollView ne marche pas du tout.
    Quand je remplis mon premier EditText(edittextViewRejet), la ListView(list) disparait petit à petit de l'écran jusqu'à qu'il ne reste plus qu'une seule ligne et impossible de la faire défiler.

    Bernard

    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"?>
    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:fillViewport="true"> <!--IMPORTANT otherwise backgrnd img. will not fill the whole screen -->
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="250dp">
     
            <TextView
                android:id="@+id/textViewRejet"
                android:layout_width="match_parent"
                android:layout_height="75dp"
                android:text="Liste des numeros bloques : "
                android:textAppearance="?android:attr/textAppearanceLarge" />
     
            <EditText
                android:layout_below="@id/textViewRejet"
                android:id="@+id/edittextViewRejet"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="top"
                android:inputType="textMultiLine" />
     
            <Button
                android:layout_below="@id/edittextViewRejet"
                android:id="@+id/buttonSMS"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:onClick="updatesms"
                android:text="Valider pour bloquer les SMS" />
     
            <Button
                android:layout_below="@id/buttonSMS"
                android:id="@+id/buttonTEL"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:onClick="updatetel"
                android:text="Valider pour bloquer les Appels" />
     
            <TextView
                android:layout_below="@id/buttonTEL"
                android:id="@+id/textViewSMS"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Texte du SMS de rejet : "
                android:textAppearance="?android:attr/textAppearanceLarge" />
     
     
            <EditText
                android:layout_below="@id/buttonTEL"
                android:id="@+id/editTextSMS"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:gravity="top"
                android:inputType="textMultiLine" />
     
            <ListView
                android:layout_below="@id/editTextSMS"
                android:id="@+id/list"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"></ListView>
     
        </RelativeLayout>
     
    </ScrollView>

  4. #4
    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,

    Citation Envoyé par Bernard74 Voir le message
    Quand je remplis mon premier EditText(edittextViewRejet), la ListView(list) disparait petit à petit de l'écran jusqu'à qu'il ne reste plus qu'une seule ligne et impossible de la faire défiler.

    Bernard

    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"?>
    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:fillViewport="true"> <!--IMPORTANT otherwise backgrnd img. will not fill the whole screen -->
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="250dp">
     
            <TextView
                android:id="@+id/textViewRejet"
                android:layout_width="match_parent"
                android:layout_height="75dp"
                android:text="Liste des numeros bloques : "
                android:textAppearance="?android:attr/textAppearanceLarge" />
     
            <EditText
                android:layout_below="@id/textViewRejet"
                android:id="@+id/edittextViewRejet"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="top"
                android:inputType="textMultiLine" />
     
            <Button
                android:layout_below="@id/edittextViewRejet"
                android:id="@+id/buttonSMS"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:onClick="updatesms"
                android:text="Valider pour bloquer les SMS" />
     
            <Button
                android:layout_below="@id/buttonSMS"
                android:id="@+id/buttonTEL"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:onClick="updatetel"
                android:text="Valider pour bloquer les Appels" />
     
            <TextView
                android:layout_below="@id/buttonTEL"
                android:id="@+id/textViewSMS"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Texte du SMS de rejet : "
                android:textAppearance="?android:attr/textAppearanceLarge" />
     
     
            <EditText
                android:layout_below="@id/buttonTEL"
                android:id="@+id/editTextSMS"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:gravity="top"
                android:inputType="textMultiLine" />
     
            <ListView
                android:layout_below="@id/editTextSMS"
                android:id="@+id/list"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"></ListView>
     
        </RelativeLayout>
     
    </ScrollView>
    Remplace
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    android:layout_height="250dp"
    par
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    android:layout_height="match_parent"

    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.

  5. #5
    Membre du Club
    Profil pro
    Inscrit en
    Février 2003
    Messages
    49
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2003
    Messages : 49
    Points : 49
    Points
    49
    Par défaut
    Bonjour,
    J'ai fait cette modification, mais le ScrollView ne fonctionne toujours pas.
    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
    <?xml version="1.0" encoding="utf-8"?>
    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:fillViewport="true"> <!--IMPORTANT otherwise backgrnd img. will not fill the whole screen -->
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">
     
            <TextView
                android:id="@+id/textViewRejet"
                android:layout_width="match_parent"
                android:layout_height="75dp"
                android:text="Liste des numeros bloques : "
                android:textAppearance="?android:attr/textAppearanceLarge" />
     
            <EditText
                android:layout_below="@id/textViewRejet"
                android:id="@+id/edittextViewRejet"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="top"
                android:inputType="textMultiLine" />
     
            <Button
                android:layout_below="@id/edittextViewRejet"
                android:id="@+id/buttonSMS"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:onClick="updatesms"
                android:text="Valider pour bloquer les SMS" />
     
            <Button
                android:layout_below="@id/buttonSMS"
                android:id="@+id/buttonTEL"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:onClick="updatetel"
                android:text="Valider pour bloquer les Appels" />
     
            <TextView
                android:layout_below="@id/buttonTEL"
                android:id="@+id/textViewSMS"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Texte du SMS de rejet : "
                android:textAppearance="?android:attr/textAppearanceLarge" />
     
     
            <EditText
                android:layout_below="@id/buttonTEL"
                android:id="@+id/editTextSMS"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:gravity="top"
                android:inputType="textMultiLine" />
     
            <ListView
                android:layout_below="@id/editTextSMS"
                android:id="@+id/list"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"></ListView>
     
        </RelativeLayout>
     
    </ScrollView>

  6. #6
    Membre du Club
    Profil pro
    Inscrit en
    Février 2003
    Messages
    49
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2003
    Messages : 49
    Points : 49
    Points
    49
    Par défaut
    J'ai trouvé cette solution qui fonctionne :

    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
    <?xml version="1.0" encoding="utf-8"?>
    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:fillViewport="true"> <!--IMPORTANT otherwise backgrnd img. will not fill the whole screen -->
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">
     
            <TextView
                android:id="@+id/textViewRejet"
                android:layout_width="match_parent"
                android:layout_height="30dp"
                android:text="Liste des numeros bloques : "
                android:textAppearance="?android:attr/textAppearanceLarge" />
     
            <EditText
                android:id="@+id/edittextViewRejet"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/textViewRejet"
                android:background="#FF0000"
                android:gravity="top"
                android:inputType="textMultiLine"
                android:maxLines="3" />
     
     
            <Button
                android:id="@+id/buttonSMS"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_below="@id/edittextViewRejet"
                android:background="#81BEF7"
                android:onClick="updatesms"
                android:text="Bloquer les SMS" />
     
            <Button
                android:id="@+id/buttonTEL"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_below="@id/edittextViewRejet"
                android:background="#81BEF7"
                android:onClick="updatetel"
                android:text="Bloquer les Appels" />
     
            <TextView
                android:id="@+id/textViewSMS"
                android:layout_width="match_parent"
                android:layout_height="30dp"
                android:layout_below="@id/buttonTEL"
                android:text="Texte du SMS de rejet : "
                android:textAppearance="?android:attr/textAppearanceLarge" />
     
            <EditText
                android:id="@+id/editTextSMS"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/textViewSMS"
                android:background="#9FE855"
                android:gravity="top"
                android:inputType="textMultiLine"
                android:maxLines="2" />
     
            <ListView
                android:id="@+id/list"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/editTextSMS"></ListView>
     
        </RelativeLayout>
     
    </ScrollView>

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

Discussions similaires

  1. Problème de défilement avec une ScrollView
    Par Nylwen dans le forum Android
    Réponses: 2
    Dernier message: 17/08/2012, 14h53
  2. Widget perso : Une grille 2D avec 3 Scrollviews
    Par odissey dans le forum Android
    Réponses: 5
    Dernier message: 16/04/2011, 11h16
  3. ScrollView inactive avec LinearLayouts imbriqués ?
    Par pataguillon dans le forum Android
    Réponses: 8
    Dernier message: 09/03/2011, 18h04
  4. Scrollview avec plusieurs Textview
    Par clege dans le forum Composants graphiques
    Réponses: 2
    Dernier message: 20/02/2011, 17h12
  5. Utilisation des ScrollBar avec un ScrollView
    Par vanitom dans le forum MFC
    Réponses: 3
    Dernier message: 11/04/2007, 10h45

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