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 :

ScrollView avec LinearLayout


Sujet :

Android

  1. #1
    Membre à l'essai
    Homme Profil pro
    formation dévellopement sur mobile
    Inscrit en
    Octobre 2014
    Messages
    4
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : Belgique

    Informations professionnelles :
    Activité : formation dévellopement sur mobile

    Informations forums :
    Inscription : Octobre 2014
    Messages : 4
    Par défaut ScrollView avec LinearLayout
    Bonjour,
    J'essaye de faire une scroolView contenant des LinearLayout mais voila arriver a mon deuxième LinearLayout les ImageButton ne se positionne pas comme désirée.
    Voici ce que sa donne.

    Nom : 1.png
Affichages : 155
Taille : 39,9 Ko

    Voici le code

    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
    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
        android:layout_height="match_parent"
     
     
        tools:context=".layout_choix_activity">
     
     
     
        <LinearLayout
            android:id="@+id/block"
            android:orientation="vertical"
            android:layout_width="wrap_content"
            android:layout_height="match_parent">
        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            >
     
        <ImageButton
            android:scaleType="fitCenter"
            android:adjustViewBounds="true"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:src="@drawable/restaurant"
            android:id="@+id/restaurant"
            android:layout_weight="1.0"
     
            />
        <ImageButton
            android:scaleType="fitCenter"
            android:adjustViewBounds="true"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/party"
            android:id="@+id/party"
            android:layout_weight="1.0"
     
            />
     
            <ImageButton
                android:scaleType="fitCenter"
                android:adjustViewBounds="true"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/sport"
                android:id="@+id/sport"
                android:layout_weight="1.0"
     
                />
     
        </LinearLayout>
     
     
        <LinearLayout
     
            android:layout_width="match_parent"
            android:layout_height="128dp"
            android:orientation="horizontal"
            >
            <ImageButton
     
                android:scaleType="fitCenter"
                android:adjustViewBounds="true"
                android:src="@drawable/cinema"
                android:id="@+id/cinema"
                android:layout_width="wrap_content"
                android:layout_height="match_parent" />
            <ImageButton
                android:scaleType="fitCenter"
                android:adjustViewBounds="true"
                android:src="@drawable/promenade"
                android:id="@+id/promenade"
                android:layout_weight="1.0"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />
     
            <ImageButton
                android:scaleType="fitCenter"
                android:adjustViewBounds="true"
                android:src="@drawable/verre"
                android:id="@+id/verre"
                android:layout_weight="1.0"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />
     
        </LinearLayout>
     
     
       </LinearLayout>
     
     
    </ScrollView>
    J'aimerais que le deuxième LinearLayout se comporte comme le premier.
    Merci de votre aide.

  2. #2
    Membre expérimenté
    Homme Profil pro
    Étudiant
    Inscrit en
    Juillet 2013
    Messages
    149
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Juillet 2013
    Messages : 149
    Par défaut
    T'as pas mis de layout_weight sur la 1ere image de la 2e ligne

  3. #3
    Membre à l'essai
    Homme Profil pro
    formation dévellopement sur mobile
    Inscrit en
    Octobre 2014
    Messages
    4
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : Belgique

    Informations professionnelles :
    Activité : formation dévellopement sur mobile

    Informations forums :
    Inscription : Octobre 2014
    Messages : 4
    Par défaut
    Merci

  4. #4
    Modérateur
    Avatar de Hizin
    Homme Profil pro
    Développeur mobile
    Inscrit en
    Février 2010
    Messages
    2 180
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : France

    Informations professionnelles :
    Activité : Développeur mobile

    Informations forums :
    Inscription : Février 2010
    Messages : 2 180
    Par défaut
    Le plus simple étant d'avoir des images de mêmes dimensions pour ne pas se prendre la tête et alléger les calculs.
    C'est Android, PAS Androïd, ou Androïde didiou !
    Le premier est un OS, le second est la mauvaise orthographe du troisième, un mot français désignant un robot à forme humaine.

    Membre du comité contre la phrase "ça marche PAS" en titre et/ou explication de problème.

    N'oubliez pas de consulter les FAQ Android et les cours et tutoriels Android

  5. #5
    Membre chevronné
    Profil pro
    Inscrit en
    Juillet 2012
    Messages
    476
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2012
    Messages : 476
    Par défaut
    Si tu comptes rajouter des images, tourne toi plutot vers une GridView, c'est fait pour.

Discussions similaires

  1. Problème avec LinearLayout imbriqués
    Par ridecat dans le forum Android
    Réponses: 4
    Dernier message: 29/08/2011, 22h52
  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