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

API standards et tierces Android Discussion :

LinearLayout API Google Maps


Sujet :

API standards et tierces Android

  1. #1
    Membre du Club
    Profil pro
    Étudiant
    Inscrit en
    Avril 2009
    Messages
    53
    Détails du profil
    Informations personnelles :
    Localisation : France, Marne (Champagne Ardenne)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Avril 2009
    Messages : 53
    Points : 58
    Points
    58
    Par défaut LinearLayout API Google Maps
    Bonjour à tous,

    J'aimerai réaliser une vue en la découpant en 3 parties de haut en bas.

    1ere partie : 3 boutons alignés dans un layout qui fait 25% de haut.
    2e partie : ma carte Google Maps sur 50% de hauteur
    3e partie : des informations relatives à mon application sur 25% de haut.

    Cependant avec la configuration de mon main.xml, je n'arrive pas du tout à ce resultats et je pense que cela est dut au comportement de ma carte Google Maps.

    Au final, je me retrouve avec ma partie haute qui fait la hauteur de mes boutons, soit 10% de la hauteur de mon ecran.
    Ma carte Google Maps prend le reste de la place sur le bas.
    Ma derniere partie est donc invisible.

    Je vous fournis le code XML

    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
     
    <?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="fill_parent"
        android:orientation="vertical"
        android:weightSum="1.0">
     
     
        <LinearLayout 
    		xmlns:android="http://schemas.android.com/apk/res/android"
    	   	android:orientation="horizontal"
    	   	android:layout_width="fill_parent"
    	   	android:layout_height="wrap_content"
    	   	android:layout_weight="0.25"
    	   	android:background="#2fb9c0"
    	   	>
     
    	    <LinearLayout 
    	        xmlns:android="http://schemas.android.com/apk/res/android"
    	   		android:orientation="horizontal"
    	   		android:layout_width="fill_parent"
    		   	android:layout_height="wrap_content"
    		   	android:layout_weight="1">
     
    	    	<Button 
    		        android:id="@+id/btnStartTrack"
    		        android:layout_width="fill_parent"
    		    	android:layout_height="wrap_content"
    		    	android:text="Start"
    	 		/>
     
    	    </LinearLayout>
     
    	    <LinearLayout 
    	        xmlns:android="http://schemas.android.com/apk/res/android"
    	   		android:orientation="horizontal"
    	   		android:layout_width="fill_parent"
    		   	android:layout_height="wrap_content"
    		   	android:layout_weight="1">
     
    	    	<Button 
    		        android:id="@+id/btnStopTrack"
    		        android:layout_width="fill_parent"
    		    	android:layout_height="wrap_content"
    		    	android:text="Stop"
    	 		/>
     
    	    </LinearLayout>
     
    	        <LinearLayout 
    	        xmlns:android="http://schemas.android.com/apk/res/android"
    	   		android:orientation="horizontal"
    	   		android:layout_width="fill_parent"
    		   	android:layout_height="wrap_content"
    		   	android:layout_weight="1">
     
    	    	<Button 
    		        android:id="@+id/btnClearTrack"
    		        android:layout_width="fill_parent"
    		    	android:layout_height="wrap_content"
    		    	android:text="Clear"
    	 		/>
     
    	    </LinearLayout>
    	</LinearLayout>
     
     
    	<LinearLayout 
    		 xmlns:android="http://schemas.android.com/apk/res/android"
    		 android:orientation="vertical"
    		 android:layout_width="fill_parent"
    		 android:layout_height="wrap_content"
    		 android:layout_weight="0.5"
    		 android:background="#aa2fc0">
     
    	    <com.google.android.maps.MapView
    		    android:id="@+id/mapView"
    			android:layout_width="fill_parent"
    			android:layout_height="fill_parent"
    			android:enabled="true"
    			android:clickable="true"
    			android:apiKey="@string/mapKey"
    		/>
     
    	</LinearLayout>
    	<LinearLayout
    	    xmlns:android="http://schemas.android.com/apk/res/android"
    	    android:orientation="horizontal"
    	    android:layout_width="fill_parent"
    	    android:layout_height="wrap_content"
    	    android:layout_weight="0.25"
    	    android:background="#66c02f"
    	 >
     
    	</LinearLayout>
    </LinearLayout>
    J'ai essayé différentes configuration mais impossible d'avoir le rendu désiré.

    Je vous remercie d'avance.

  2. #2
    Membre actif Avatar de chpil
    Homme Profil pro
    Inscrit en
    Octobre 2011
    Messages
    143
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations forums :
    Inscription : Octobre 2011
    Messages : 143
    Points : 212
    Points
    212
    Par défaut
    J'ai remarqué, lorsque j'utilise les poids (layout_weight), qu'il fallait que je mette la taille (layout_height ou layout_width, suivant l'orientation du LinearLayout) à 0dp pour que le mécanisme des poids fonctionne.
    Ce qui donnerai
    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
    <?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="fill_parent"
        android:orientation="vertical"
        android:weightSum="1.0">
     
     
        <LinearLayout 
    		xmlns:android="http://schemas.android.com/apk/res/android"
    	   	android:orientation="horizontal"
    	   	android:layout_width="fill_parent"
    	   	android:layout_height="0dp"
    	   	android:layout_weight="0.25"
    	   	android:background="#2fb9c0"
    	   	>
     
    	    	<Button 
    		        android:id="@+id/btnStartTrack"
    		        android:layout_width="0dp"
    		    	android:layout_height="wrap_content"
    		   	android:layout_weight="1"
    		    	android:text="Start"
    	 		/>
     
    	    	<Button 
    		        android:id="@+id/btnStopTrack"
    		        android:layout_width="0dp"
    		    	android:layout_height="wrap_content"
                    android:layout_weight="1"
    		    	android:text="Stop"
    	 		/>
     
    	    	<Button 
    		        android:id="@+id/btnClearTrack"
    		        android:layout_width="0dp"
    		    	android:layout_height="wrap_content"
                    android:layout_weight="1"
    		    	android:text="Clear"
    	 		/>
     
    	</LinearLayout>
     
     
    	<LinearLayout 
    		 xmlns:android="http://schemas.android.com/apk/res/android"
    		 android:orientation="vertical"
    		 android:layout_width="fill_parent"
    		 android:layout_height="0dp"
    		 android:layout_weight="0.5"
    		 android:background="#aa2fc0">
     
    	    <com.google.android.maps.MapView
    		    android:id="@+id/mapView"
    			android:layout_width="fill_parent"
    			android:layout_height="fill_parent"
    			android:enabled="true"
    			android:clickable="true"
    			android:apiKey="@string/mapKey"
    		/>
     
    	</LinearLayout>
    	<LinearLayout
    	    xmlns:android="http://schemas.android.com/apk/res/android"
    	    android:orientation="horizontal"
    	    android:layout_width="fill_parent"
    	    android:layout_height="0dp"
    	    android:layout_weight="0.25"
    	    android:background="#66c02f"
    	 >
     
    	</LinearLayout>
    </LinearLayout>
    (en enlevant par la même occasion les LinearLayout inutiles

  3. #3
    Expert éminent

    Homme Profil pro
    Ingénieur systèmes et réseaux
    Inscrit en
    Février 2007
    Messages
    4 253
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Ingénieur systèmes et réseaux
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Février 2007
    Messages : 4 253
    Points : 7 618
    Points
    7 618
    Billets dans le blog
    3
    Par défaut
    Je n'ai pas ce probleme du tout pour les poids... wrap_content & layout_weight font bien leur boulot chez moi...

    Pour couper 25/50/25 je ne vois que cette solution...
    Par contre, je ne sais pas si le weight acceptent bien les décimales (j'ai toujours utilisé des entiers: 1,2,1, sum=4)
    N'oubliez pas de cliquer sur mais aussi sur si un commentaire vous a été utile !
    Et surtout

  4. #4
    Expert éminent

    Avatar de Feanorin
    Profil pro
    Inscrit en
    Avril 2004
    Messages
    4 589
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 4 589
    Points : 9 149
    Points
    9 149
    Par défaut
    Je n'ai pas ce probleme du tout pour les poids... wrap_content & layout_weight font bien leur boulot chez moi...
    Pareil.

    Par contre, je ne sais pas si le weight acceptent bien les décimales (j'ai toujours utilisé des entiers: 1,2,1, sum=4)
    Il me semble qu'il prends que des floattant

    public float weight

    Since: API Level 1
    Indicates how much of the extra space in the LinearLayout will be allocated to the view associated with these LayoutParams. Specify 0 if the view should not be stretched. Otherwise the extra pixels will be pro-rated among all views whose weight is greater than 0.
    Après c'est toujours plus simple de travailler avec des entiers ^^
    Responsable Android de Developpez.com (Twitter et Facebook)
    Besoin d"un article/tutoriel/cours sur Android, consulter la page cours
    N'hésitez pas à consulter la FAQ Android et à poser vos questions sur les forums d'entraide mobile d'Android.

  5. #5
    Membre du Club
    Profil pro
    Étudiant
    Inscrit en
    Avril 2009
    Messages
    53
    Détails du profil
    Informations personnelles :
    Localisation : France, Marne (Champagne Ardenne)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Avril 2009
    Messages : 53
    Points : 58
    Points
    58
    Par défaut
    Bonjour à tous,

    Je viens d"essayer de passer mes valeurs en entier mais le résultat est le même.
    Cependant, j'ai utilisé la méthode de chpil est dans ce cas, j'ai le résultat attendu.
    Je ne sais pas pourquoi, sans la intégrer ma carte Google Maps, je n'ai pas ce soucis mais dès que je l'intègre, je suis obligé de mettre "0dp".

    Merci à tous, je vais conserver cette méthode.

  6. #6
    Inscrit

    Profil pro
    Inscrit en
    Février 2008
    Messages
    658
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2008
    Messages : 658
    Points : 892
    Points
    892
    Par défaut
    Voici comment moi je ferai si j'etais à ta place!

    Trop de linearLyout: Ce qui ralentit la construction de la view


    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"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical"
        android:weightSum="1.0">
     
     
        <LinearLayout 
    		android:layout_width="fill_parent"
    	   	android:layout_height="wrap_content"
    	   	android:background="#2fb9c0"
    	   	android:padding="5dip">
     
            <Button
                android:id="@+id/btnStartTrack"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="Start" />
     
    	    <Button
    	        android:id="@+id/btnStopTrack"
    	        android:layout_width="fill_parent"
    	        android:layout_height="wrap_content"
    	        android:layout_weight="1"
    	        android:text="Stop" />
     
    	    <Button
    	        android:id="@+id/btnClearTrack"
    	        android:layout_width="fill_parent"
    	        android:layout_height="wrap_content"
    	        android:layout_weight="1"
    	        android:text="Clear" />
    	</LinearLayout>
     
     
    	<LinearLayout 
    		 xmlns:android="http://schemas.android.com/apk/res/android"
    		 android:orientation="vertical"
    		 android:layout_width="fill_parent"
    		 android:layout_height="wrap_content"
    		 android:background="#aa2fc0" android:layout_weight="1.0">
     
    	    <com.google.android.maps.MapView
    		    android:id="@+id/mapView"
    			android:layout_width="fill_parent"
    			android:layout_height="fill_parent"
    			android:enabled="true"
    			android:clickable="true"
    			android:apiKey="string/mapKey"
    		/>
     
    	</LinearLayout>
    	<LinearLayout
    	    xmlns:android="http://schemas.android.com/apk/res/android"
    	    android:orientation="horizontal"
    	    android:layout_width="fill_parent"
    	    android:layout_height="wrap_content"
    	    android:layout_weight="1"
    	    android:background="#66c02f"
    	 android:gravity="center" android:padding="5dip">
     
    		<Button
    		    android:id="@+id/button1"
    		    android:layout_width="wrap_content"
    		    android:layout_height="wrap_content"
    		    android:text="Button" />
     
    	</LinearLayout>
     
    </LinearLayout>

  7. #7
    Expert éminent

    Avatar de Feanorin
    Profil pro
    Inscrit en
    Avril 2004
    Messages
    4 589
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 4 589
    Points : 9 149
    Points
    9 149
    Par défaut
    Bonjour,

    Si vous avez la réponse à votre question n'oubliez pas de mettre votre sujet en résolu, grâce au bouton en bas de la page .

    Responsable Android de Developpez.com (Twitter et Facebook)
    Besoin d"un article/tutoriel/cours sur Android, consulter la page cours
    N'hésitez pas à consulter la FAQ Android et à poser vos questions sur les forums d'entraide mobile d'Android.

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

Discussions similaires

  1. API Google Map
    Par jpower dans le forum EDI, CMS, Outils, Scripts et API
    Réponses: 2
    Dernier message: 19/11/2007, 22h43
  2. [MySQL] Utilisation de l'API Google Maps
    Par nagadef dans le forum PHP & Base de données
    Réponses: 2
    Dernier message: 11/07/2007, 21h37
  3. API Google maps
    Par XGotX dans le forum Windows
    Réponses: 4
    Dernier message: 28/01/2007, 16h31
  4. [Google Maps] IE6 refuse d'ouvrir ma page
    Par Shyboy dans le forum APIs Google
    Réponses: 5
    Dernier message: 03/10/2006, 08h47
  5. [Google Maps] Intégrer de nouvelles icônes
    Par Shyboy dans le forum APIs Google
    Réponses: 7
    Dernier message: 01/10/2006, 00h30

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