Bonjour,
je suis en train de réaliser une page qui va afficher une liste de magasin suivant un item particulier. En gros ce que je voudrais c'est sa :
Magasin 1 Btn1 Btn2
adresse du magasin1
Magasin 2 Btn1 Btn2
adresse du magasin2
Néanmoins suivant le nom du magasin tout est décalé. Je voudrais que les boutons soient toujours alignés. Et que si un nom, ou une adresse, soient trop long cela ne décale pas tout le design (par exemple on a le début du nom suivi de pointillé, que sa ne prenne pas une seconde ligne).
Mon problème est surement du au fait que je n'ai pas fait les choses d'une bonne manière... néanmoins j'ai assez de mal avec l'utilisation des layouts.
Voici le code d'un item : item.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
74
75
76 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:baselineAligned="false" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" android:weightSum="10" > <LinearLayout android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="1" android:orientation="vertical" > </LinearLayout> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="6" android:orientation="vertical" > <TextView android:id="@+id/etName" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Medium Text" android:textAppearance="?android:attr/textAppearanceLarge" /> <TextView android:id="@+id/etAdress" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Small Text" android:textAppearance="?android:attr/textAppearanceMedium" /> </LinearLayout> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" android:orientation="vertical" > <ImageButton android:id="@+id/btnMap" android:layout_width="wrap_content" android:layout_height="wrap_content" android:contentDescription="view map" android:src="@android:drawable/ic_menu_search" /> </LinearLayout> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" android:orientation="vertical" > <ImageButton android:id="@+id/btInfo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:contentDescription="view info" android:src="@android:drawable/ic_dialog_info" /> </LinearLayout> <LinearLayout android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="1" android:orientation="vertical" > </LinearLayout> </LinearLayout>
Et le code de la liste : liste.xml
Les poids que j'ai associé à certain layout sont important pour que l'appli puisse s'adapter aux différents types de mobile / tablette utilisés.
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="fill_parent" android:layout_height="fill_parent" android:background="@drawable/cheri_paris_fond" android:orientation="vertical" android:weightSum="10" > <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1.5" android:orientation="vertical" > </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:orientation="horizontal" > <TextView android:id="@+id/textView1" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:text=" Liste des magasins" android:textAppearance="?android:attr/textAppearanceLarge" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="@dimen/activity_horizontal_margin" android:layout_weight="7.5"> <ListView android:id="@+id/lstMag" android:layout_width="match_parent" android:layout_height="match_parent"> </ListView> </LinearLayout> </LinearLayout>
Si quelqu'un pourrait m'expliquer comment réaliser ce "design" sa m'aiderait beaucoup. Merci à vous
Partager