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 :

Séparer une activité et y lancer la caméra


Sujet :

API standards et tierces Android

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éclairé
    Profil pro
    Inscrit en
    Décembre 2003
    Messages
    422
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2003
    Messages : 422
    Par défaut Séparer une activité et y lancer la caméra
    Hello !

    Alors je débute en dev Android, donc merci d'être indulgent

    Voila, j'ai une activité principale avec un linearLayout qui prend tout l'écran, en mode vertical. J'aimerai séparer celui-ci en 2 parties :
    1- 3/4 de la partie haute, où figurerait la vue de la caméra (ou de l'appareil photo, c'est pareil je pense)
    2- 1/4 du bas pour y placer 3 boutons fixes (eux aussi dans un linearLayout).

    Dans le (1), j'aimerai afficher la vue de la caméra (sans forcément enregistrer une vidéo, pour le moment).

    Je rencontre 2 soucis (distincts certes):
    a- Je n'arrive pas à déplacer (2) tout en bas de l'écran
    b- je ne sais pas bien comment m'y prendre pour afficher la vue de l'écran dans (1)

    Voici le code de mon fichier main.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
     
    <?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="wrap_content"
        android:orientation="vertical" >
     
        <LinearLayout
            android:id="@+id/layoutCamera"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:baselineAligned="true" >
     
        <!-- Vue caméra --> 
     
        </LinearLayout>    
     
     
        <LinearLayout
            android:id="@+id/layoutMenu"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:baselineAligned="true"
            android:layout_gravity="bottom"  >
     
            <Button
                android:id="@+id/Button1"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_gravity="bottom"
                android:layout_weight="1"
                android:text="Play" />
     
            <Button
                android:id="@+id/button2"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:text="Pause" />
     
            <Button
                android:id="@+id/button3"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:text="Rest Area" />
     
        </LinearLayout>
     
    </LinearLayout>
    Ce code affiche bien les 3 boutons fixes mais en haut de l'écran ...

    Voila si vous avez besoin de données complémentaires dites moi.

    Merci pour votre aide

  2. #2
    Membre actif Avatar de FF_enec
    Homme Profil pro
    Étudiant
    Inscrit en
    Novembre 2011
    Messages
    43
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Novembre 2011
    Messages : 43
    Par défaut
    Bonjour,

    Tu peux ajouter des LinearLayout dans les LinearLayout eux même.

    Tu peux également modifier l'emplacement des composants selon leur "poids".
    La hauteur et la largeur est soit selon l'élément parent ou fils.

    Avec ceci, il sera simple de mettre les composants ou tu veux.

    Je te renvoi aux sources : http://developer.android.com/guide/t...ex.html#Layout

    Cordialement

  3. #3
    Membre éclairé
    Profil pro
    Inscrit en
    Décembre 2003
    Messages
    422
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2003
    Messages : 422
    Par défaut
    Merci de ta réponse,

    Tu peux ajouter des LinearLayout dans les LinearLayout eux même.
    C'est bien ce que j'ai fait : j'ai un 2e LinearLayout (ligne 19 dans mon code) qui est sensé étre en bas (gravity : bottom) et pourtant, il reste en haut ...

  4. #4
    Membre actif Avatar de FF_enec
    Homme Profil pro
    Étudiant
    Inscrit en
    Novembre 2011
    Messages
    43
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Novembre 2011
    Messages : 43
    Par défaut
    Regarde du coté des "poids".

    Tu peux lui dire que tel composant doit occupé 1/4 de l'écran et que l'autre tout le reste.

    Voici un lien utile : http://android.developpez.com/cours/


    Exemple :
    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
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:orientation="vertical"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
     >
    <Button
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:text="Button 1"
     android:layout_weight="2"
     />
     
     <Button
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:text="Button 2"
     android:layout_weight="1"
     />
     
    </LinearLayout>

  5. #5
    Membre éclairé
    Profil pro
    Inscrit en
    Décembre 2003
    Messages
    422
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2003
    Messages : 422
    Par défaut
    Bizzare, j'ai rajouté les poids aux LinearLayout internes (respectivement égale à 2 et 1) et ça ne change rien ...

    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
     
    <?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="wrap_content"
        android:orientation="vertical" >
     
        <LinearLayout
            android:id="@+id/layoutCamera"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:baselineAligned="true" 
            android:layout_weight="2" >
     
        </LinearLayout>    
     
        <LinearLayout
            android:id="@+id/layoutMenu"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:baselineAligned="true"
            android:layout_weight="1"
            android:layout_gravity="bottom" >
     
            <Button
                android:id="@+id/button1"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_gravity="bottom"
                android:layout_weight="1"
                android:text="Play" />
     
            <Button
                android:id="@+id/button2"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:text="Pause" />
     
            <Button
                android:id="@+id/button3"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:text="Rest Area" />
     
        </LinearLayout>
     
    </LinearLayout>

  6. #6
    Membre actif Avatar de FF_enec
    Homme Profil pro
    Étudiant
    Inscrit en
    Novembre 2011
    Messages
    43
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Novembre 2011
    Messages : 43
    Par défaut
    Alors déjà enlève le gravity.

    Pour les 2 LinearLayout que tu veux placer mets plutôt :

    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
     
    <?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="wrap_content"
        android:orientation="vertical" >
     
        <LinearLayout
            android:id="@+id/layoutCamera"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="2" >
     
        </LinearLayout>    
     
        <LinearLayout
            android:id="@+id/layoutMenu"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1">
     
            <Button
                android:id="@+id/button1"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_gravity="bottom"
                android:layout_weight="1"
                android:text="Play" />
     
            <Button
                android:id="@+id/button2"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:text="Pause" />
     
            <Button
                android:id="@+id/button3"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:text="Rest Area" />
     
        </LinearLayout>
     
    </LinearLayout>
    Sinon pour ton menu, pourquoi n'utilises tu pas la fonction donnée par java "Menu" : http://developer.android.com/guide/topics/ui/menus.html

Discussions similaires

  1. Lancer une activité dans le même layout
    Par n99ky dans le forum Composants graphiques
    Réponses: 1
    Dernier message: 10/04/2012, 05h06
  2. Notification lancer une activité
    Par Sake_reflex dans le forum Android
    Réponses: 2
    Dernier message: 09/08/2011, 02h02
  3. Comment lancer une activité en random
    Par jeremy276 dans le forum Android
    Réponses: 2
    Dernier message: 26/06/2011, 00h19
  4. Séparer une chaine en sous chaine
    Par firemax dans le forum C
    Réponses: 9
    Dernier message: 03/06/2005, 12h23
  5. Séparer une base de données ?
    Par fredouille31 dans le forum Outils
    Réponses: 2
    Dernier message: 20/05/2005, 13h32

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