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 :

Problème affichage avec les Layouts


Sujet :

Composants graphiques Android

  1. #1
    Membre régulier

    Homme Profil pro
    Étudiant Réseaux et Télécoms
    Inscrit en
    Octobre 2009
    Messages
    121
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 32
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Étudiant Réseaux et Télécoms
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Octobre 2009
    Messages : 121
    Points : 92
    Points
    92
    Par défaut Problème affichage avec les Layouts
    Bonsoir à tous,

    Nous avons un gros problème d'affichage de notre menu. Enfin, pour que ce là marche nous mettons en brut le nombre de px ou doit situé chaque objet(Button,TextView)... Or comment faire pour que l'affichage fonctionne sur tous les portables, on peut pas utiliser de %?

    Voici ce que l'on affiche(Sur l'émulateur c'est très bof):





    Et voici le fichier.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
    <?xml version="1.0" encoding="utf-8"?>
     
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent">
     
     
     		<TextView 
    		android:textStyle="bold" 
    		android:gravity="center"
    		android:layout_gravity="center" 
    		android:visibility="visible" 
    		android:layout_height="wrap_content" 
    		android:layout_width="fill_parent" 
    		android:layout_marginTop="15px"
    		android:text="SimplyBus"
    		android:textColor="#FFFFFF"
    		android:textSize="20px"
    		/>
     
    		<Button
            android:id="@+id/button"
            android:layout_width="100px"
            android:layout_height="100px"
            android:padding="10dp"
            android:layout_marginTop="90px"
            android:layout_marginLeft="45px"
            android:background="@drawable/android_map"
            />
     
            <TextView 
    		android:textStyle="bold" 
    		android:gravity="right"
    		android:visibility="visible" 
    		android:layout_height="wrap_content" 
    		android:layout_width="fill_parent" 
    		android:text="SimplyBus"
    		android:textColor="#FFFFFF"
    		android:textSize="10px"
    		android:layout_marginTop="450px"
    		/>
     
    		<Button
            android:id="@+id/button1"
            android:layout_width="100px"
            android:layout_height="100px"
            android:padding="10dp"
            android:layout_marginTop="90px"
            android:layout_marginLeft="185px"
            android:background="@drawable/android_infos"
            />
     
            <Button
            android:id="@+id/button2"
            android:layout_width="100px"
            android:layout_height="100px"
            android:padding="10dp"
            android:layout_marginTop="270px"
            android:layout_marginLeft="45px"
            android:background="@drawable/android_bus"
            />
     
            <Button
            android:id="@+id/button3"
            android:layout_width="100px"
            android:layout_height="100px"
            android:padding="10dp"
            android:layout_marginTop="270px"
            android:layout_marginLeft="185px"
            android:background="@drawable/android_bus"
            />
     
    </RelativeLayout>

    Merci de votre aide!

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

    Il me semble que le sujet a été abordé sur un autre post

    px
    Pixels - corresponds to actual pixels on the screen.

    in
    Inches - based on the physical size of the screen.

    mm
    Millimeters - based on the physical size of the screen.

    pt
    Points - 1/72 of an inch based on the physical size of the screen.

    dp
    Density-independent Pixels - an abstract unit that is based on the physical density of the screen. These units are relative to a 160 dpi screen, so one dp is one pixel on a 160 dpi screen. The ratio of dp-to-pixel will change with the screen density, but not necessarily in direct proportion. Note: The compiler accepts both "dip" and "dp", though "dp" is more consistent with "sp".

    sp
    Scale-independent Pixels - this is like the dp unit, but it is also scaled by the user's font size preference. It is recommend you use this unit when specifying font sizes, so they will be adjusted for both the screen density and user's preference.
    Au lieu d'utiliser les px utilise de préférence les dip .

    Maintenant ,vu la vue que tu proposes ,tu devrais pouvoir t'en sortir sans passer par les distances 'brutes', en passant directement avec les placements des layout dans ta vue .

    Cordialement,

  3. #3
    Membre régulier

    Homme Profil pro
    Étudiant Réseaux et Télécoms
    Inscrit en
    Octobre 2009
    Messages
    121
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 32
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Étudiant Réseaux et Télécoms
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Octobre 2009
    Messages : 121
    Points : 92
    Points
    92
    Par défaut
    Bonjour,

    Merci de votre réponse!

    Cependant, vous me connseillez d'utilisez des RelativeLayout, LinearLayout...?


    Cordialement

  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
    Cependant, vous me connseillez d'utilisez des RelativeLayout, LinearLayout...?
    Je pense que pour ce que tu veux faire les LinearLayout correspondent le mieux.

  5. #5
    Membre régulier

    Homme Profil pro
    Étudiant Réseaux et Télécoms
    Inscrit en
    Octobre 2009
    Messages
    121
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 32
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Étudiant Réseaux et Télécoms
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Octobre 2009
    Messages : 121
    Points : 92
    Points
    92
    Par défaut
    Rebonsoir,

    J'ai trouver un tutorial interressant sur les RelativeLayout, donc j'ai essayé tout çà.

    Ce qui me donne:

    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
    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/lol"
     
    >
     
    <TextView
    android:id="@+id/text"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="SimplyBus"
    android:layout_centerHorizontal="true"
     
    android:textSize="40dp"
    android:paddingBottom="80dip"/>
     
    <ImageButton
    android:id="@+id/button1"
    android:layout_width="100px"
    android:layout_height="100px"
    android:layout_below="@id/text" 
    android:paddingBottom="10dip"
    android:layout_marginLeft="50dp" />
     
    <ImageButton
    android:id="@+id/button2"
    android:layout_toRightOf="@id/button1"
    android:layout_below="@id/text" 
    android:layout_width="100px"
    android:layout_height="100px"
    />
     
    <ImageButton
    android:id="@+id/button3"
    android:layout_width="100px"
    android:layout_height="100px"
    android:layout_below="@id/button1" 
    android:layout_marginLeft="50dp" />
    />
     
    <ImageButton
    android:id="@+id/button4"
    android:layout_toRightOf="@id/button3"
    android:layout_below="@id/button1" 
    android:layout_width="100px"
    android:layout_height="100px"
     
    />
     
    <TextView
    android:id="@+id/text2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:paddingTop="125dp"
    android:layout_marginLeft="250dp"
    android:text="Version 1.0"
    android:textSize="10dp"
    android:layout_below="@id/button3"
    />
    </RelativeLayout>
    Or mon bloc des quatres bouttons nest pas centré horizontalement, donc j'ai essayé de mettre un relative layoutimbriqué dans l'autre mais celà ne marche point.

    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
    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/lol"
    android:layout_gravity="center"
     
    >
     
    <TextView
    android:id="@+id/text"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="SimplyBus"
    android:textSize="40dp"
    android:layout_centerHorizontal="true"
    android:paddingBottom="80dip"/>
     
    <RelativeLayout
    android:layout_below="@id/text" 
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:id="@+id/lol2"
    android:layout_centerHorizontal="true"
    >
    <ImageButton
    android:id="@+id/button1"
    android:layout_width="100px"
    android:layout_height="100px"
    android:layout_below="@id/text" 
    android:paddingBottom="10dip"
     />
     
    <ImageButton
    android:id="@+id/button2"
    android:layout_toRightOf="@id/button1"
    android:layout_width="100px"
    android:layout_height="100px"
    />
     
    <ImageButton
    android:id="@+id/button3"
    android:layout_width="100px"
    android:layout_height="100px"
    android:layout_below="@id/button1" 
     />
     
     
    <ImageButton
    android:id="@+id/button4"
    android:layout_toRightOf="@id/button3"
    android:layout_below="@id/button1" 
    android:layout_width="100px"
    android:layout_height="100px"
     
    />
    </RelativeLayout> 
    <TextView
    android:id="@+id/text2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:paddingTop="125dp"
    android:layout_marginLeft="250dp"
    android:text="Version 1.0"
    android:textSize="10dp"
    android:layout_below="@id/button3"
    />
    </RelativeLayout>
    Mais celà ne marche point.

    Cordialement

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

Discussions similaires

  1. Réponses: 3
    Dernier message: 25/06/2012, 15h08
  2. Problème d'affichage avec les float
    Par Poseidon62 dans le forum Ada
    Réponses: 9
    Dernier message: 04/05/2007, 14h03
  3. Problème d'affichage avec les lumières
    Par Glosialabolas dans le forum OpenGL
    Réponses: 3
    Dernier message: 02/11/2006, 18h46
  4. [PHP-JS] Problème d'affichage avec les ', ê, é,è
    Par cyberdevelopment dans le forum Langage
    Réponses: 4
    Dernier message: 28/07/2006, 13h49
  5. Réponses: 6
    Dernier message: 19/05/2005, 11h06

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