Bonjour,
J'essaye de représenter une télécommande avec différents bouton. Je possède une image pour chaque bouton (8 au total), et je les positionne à l'aide de mon main.xml. J'essaye de les répartir à l'aide de différent layout sur la "télécommande". Cependant, étant trop gros, il ne rentre pas tous. Je les ai donc organisé dans différent layout, enfin qu'il soit placé à peu prés ou je le souhaite, cependant il dépasse, comme nous pouvons le voir ci dessous :
J'aurais donc souhaité diminuer la taille de chaque bouton en %, afin de faire en sorte que ces dernier rentre, mais je n'y arrive pas ni via le graphical layout, ni via le xml. J'ai rangé mes boutons dans plusieurs layouts :
Mon layout principal est un linearLayout, avec un fond blanc et un padding de 20, avec une orientation verticale. Ce dernier possédé un linear layout possédant en background l'image de ma télécommande vide (sans aucun bouton). J'ai ensuite rajouter 8 Buttons, chacun avec comme background l'image correspondant à son bouton. Ces derniers sont repartis à l'interieur du linearLayout de cette façon :
- Les 2 boutons du haut, GPS et EYE sont dans un relativeLayout (un en alignParentLeft, l'autre en right)
- les 2 boutons en dessous , menu et actualiser sont dans un autre relativeLayout (un en centerHorizontal et l'autre en aligneParentRight)
- les 3 boutons ensuite sont dans un autre relativeLayout (fleche gauche, menu, fleche droite ) (pareil qu'avant, un en alignParentLeft, un en centerHorizontal, et un en alignParentRight)
-enfin le dernier bouton est également dans un relativeLayout, en centerhorizontal.
J'ai volontairement mis des padding en dip pour espérer ne pas avoir à réadapter mon IHM pour les différentes tailles d'écran, cependant, ce n'est pas le cas (j'utilise certes le simulateur pour visualiser le rendu, et ce n'est pas bon du tout
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 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#FEFEFE" android:orientation="vertical" android:padding="20dip" > <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/remote_background" a,d android:orientation="vertical" > <RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:padding="30dip" > <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:background="@drawable/buttongps" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_alignParentTop="true" android:background="@drawable/buttoneye" /> </RelativeLayout> <RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:padding="15dip" > <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:background="@drawable/buttonmenu" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_marginTop="10dip" android:background="@drawable/buttonrepeat" /> </RelativeLayout> <RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:paddingRight="20dip" android:paddingLeft="20dip" > <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:background="@drawable/buttongauche" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:background="@drawable/buttonok" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:background="@drawable/buttondroit" /> </RelativeLayout> <RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" > <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:background="@drawable/buttonphone" /> </RelativeLayout> </LinearLayout> </LinearLayout>
Si quelqu'un aurait une idée ou un conseil, je suis preneur!
Merci d'avance
Partager