JeremX Posted February 10, 2011 Share Posted February 10, 2011 Bonjour, j'ai commencé à coder une appli mais j'ai un petit soucis. J'aimerai mettre une petite image en bas à droite de l'écran mais je n'y arrive pas. Je n'arrive qu'à la mettre à gauche ou à droite. <!-- Calque pour logo Android --> <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="right" > <!-- Logo Android --> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/l_android" /> </LinearLayout> J'ai créé un nouveau calque juste pour ce logo. Je sais que c'est "bottom" dans d'autres langages de programmation pour mettre une image en bas de l'écran, mais avec le XML, j'ai un peu de mal. ^^ Est-ce que vous pouvez me dire comment faire? Merci. :) Link to comment Share on other sites More sharing options...
Femto Posted February 10, 2011 Share Posted February 10, 2011 Je me suis araché les cheveux aussi la première fois. met un RelativeLayout par dessus ton LinearLayout qui prend sa taille en hauteur et largeur. Tu met ton image dans le relative layout et quand tu jouera avec les propriétés ça devrais marcher =) Link to comment Share on other sites More sharing options...
JeremX Posted February 11, 2011 Author Share Posted February 11, 2011 Merci pour ta réponse Femto, mais cela ne marche pas. Cela vient de moi sans doute, vu que je débute dans ce langage tout nouveau pour moi. :) Voici le bout de code que j'ai modifié: <!-- Calque pour logo Android --> <RelativeLayout > <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="right|bottom" > <!-- Logo Android --> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/l_android" /> </LinearLayout> </RelativeLayout> </LinearLayout> Link to comment Share on other sites More sharing options...
JeremX Posted February 15, 2011 Author Share Posted February 15, 2011 UP. :) Link to comment Share on other sites More sharing options...
Kricek Posted February 16, 2011 Share Posted February 16, 2011 Les propriétés de ton relativeLayout me semblent un peu vides... Tu devrais au moins avoir width et height...... Si tu n'as qu'une seule image à mettre, je pense que tu peux supprimer le LinearLayout et mettre directement ton image dans le relativeLayout... Donc il faudrait que ton relative fasse: android:layout_width="fill_parent" android:layout_height="fill_parent" Et que ton imageView: android:layout_alignParentRight="true" android:layout_alignParentBottom="true" Essaye et tiens moi au courant... ;) Link to comment Share on other sites More sharing options...
JeremX Posted February 16, 2011 Author Share Posted February 16, 2011 Merci beaucoup à toi Kricek, ça marche niquel! :P Si je voudrai afficher une autre image, il faudrait que je mette un LinearLayout et que je répète l'opération? Merci encore. :) Link to comment Share on other sites More sharing options...
Cyril Mottier Posted February 17, 2011 Share Posted February 17, 2011 Il ne faut pas oublier un des layouts les plus basiques : le FrameLayout. J'aurais préféré faire : <FrameLayout> android:layout_width="fill_parent" android:layout_height="fill_parent"> <!-- Logo Android --> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom|right" android:src="@drawable/l_android" /> </FrameLayout> Concernant ta question sur le positionnement d'une autre image, il faut que tu regardes comment fonctionnent les layouts sur Android. C'est primordial :) Link to comment Share on other sites More sharing options...
JeremX Posted February 17, 2011 Author Share Posted February 17, 2011 Merci pour ta réponse Cyril, je vais me pencher là-dessus un peu plus. :) Au passage, bravo pour tes tutoriels sur ton site qui sont super bien rédigés! C'est l'un des sites où je vais le plus pour apprendre à programmer sur Android. ^^ Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.