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 :

Adapter une vue à son parent


Sujet :

Android

  1. #1
    Membre habitué
    Homme Profil pro
    Inscrit en
    Octobre 2011
    Messages
    281
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Octobre 2011
    Messages : 281
    Points : 161
    Points
    161
    Par défaut Adapter une vue à son parent
    Bonjour,

    Comme vous pouvez le voir dans le code ci dessous mon ImageView a une taille fixe. J'aimerais maintenant que l'ImageView prenne 30% du LinearLayout.
    Comment faire ?

    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
    <?xml version="1.0" encoding="utf-8"?>
     
      <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     	android:orientation="vertical"
     	android:background="@drawable/bloc_article"
     	android:paddingRight="5dp"
     	android:layout_width="fill_parent"
     	android:layout_height="fill_parent">
     
    	 <LinearLayout
    	     android:layout_width="fill_parent"
    	     android:layout_height="wrap_content"
    	     android:orientation="horizontal">
     
     
    	   <ImageView 
    	    android:id="@+id/item_miniature"
    	    android:layout_width="120dp"
    	    android:layout_height="75dp" />  
     
     
     
    	     <LinearLayout
    	         android:layout_width="fill_parent"
    	         android:layout_height="wrap_content"
    	         android:paddingLeft="5dp"
    	         android:orientation="vertical">
     
    	         <TextView
    	             android:id="@+id/titre"
    	             android:layout_width="fill_parent"
    	             android:layout_height="wrap_content"
    	             android:singleLine="true"
    	             android:ellipsize="end"
    	             android:textColor="#0b3178"
    	             android:textSize="14sp" />
     
    	         <TextView
    	             android:id="@+id/date"
    	             android:layout_width="fill_parent"
    	             android:layout_height="wrap_content"
    	             android:textColor="#303030"
    	             android:textStyle="italic"
    	             android:textSize="12sp" />
     
     
    	         <TextView
    	             android:id="@+id/extrait"
    	             android:layout_width="fill_parent"
    	             android:layout_height="wrap_content"
    	             android:textColor="#000000"
    	             android:singleLine="false"
    	             android:ellipsize="end"
    	             android:lineSpacingExtra="4sp"
    	             android:maxLines="2"
    	             android:textSize="12sp" />
     
     
    	     </LinearLayout>
     
    	 </LinearLayout>
     
    </LinearLayout>

  2. #2
    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
    Si je décrypte bien:

    LinearLayout ( LinearLayout ( ImageView, LinearLayout (TextView...) ) )

    Il y a déjà un problème au premier niveau: un linearlayout qui ne contient qu'un objet de sert à rien.

    Ensuite il suffit de jouer avec les "weight"..... weight=3 pour l'ImageView, weight=7 pour le LinearLayout, totalWeight=10 pour le parent....
    N'oubliez pas de cliquer sur mais aussi sur si un commentaire vous a été utile !
    Et surtout

Discussions similaires

  1. Adapter une DIV à son contenu
    Par miltonis dans le forum Mise en page CSS
    Réponses: 6
    Dernier message: 29/04/2011, 12h14
  2. Adapter la hauteur d'une div à son contenu
    Par toufou dans le forum Général JavaScript
    Réponses: 0
    Dernier message: 07/10/2009, 14h42
  3. Réponses: 2
    Dernier message: 30/09/2009, 12h50
  4. Cacher une vue sans supprimer son contenu
    Par Elmotardo dans le forum Eclipse Platform
    Réponses: 2
    Dernier message: 03/07/2009, 09h48
  5. [ SWING ] Ouvrir une fenêtre dans son parent
    Par Invité dans le forum AWT/Swing
    Réponses: 9
    Dernier message: 12/01/2006, 16h12

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