Bonjour,
Je cherche à ajouter une ligne de division (ou une ligne de séparation) après un LinearLayout comme par exemple la ligne de séparation utilisée par défaut par une ListView.
Comment faire cela ?
Merci.
A+;
Version imprimable
Bonjour,
Je cherche à ajouter une ligne de division (ou une ligne de séparation) après un LinearLayout comme par exemple la ligne de séparation utilisée par défaut par une ListView.
Comment faire cela ?
Merci.
A+;
Essayes d'analyser comment sont fait les layouts natifs de Android, comme simple_list_item_1.xml par exemple :
http://www.netmite.com/android/mydro...es/res/layout/
Bonjour
Ce n'est pas défini de base dans les View, tu peux te créer ton composant personnalisé avec un nouveau paramètres depuis le xml ;).Citation:
Je cherche à ajouter une ligne de division (ou une ligne de séparation) après un LinearLayout comme par exemple la ligne de séparation utilisée par défaut par une ListView.
Sinon la méthode classique, tu rajoutes un view dans ton xml juste en dessous de la view ou tu veux rajouter ta ligne de séparation.
En fait pour faire simple ta View ajouter sera ta ligne de séparation exemple,
Une ligne horizontale :
Code:
1
2
3
4 <View android:layout_width="fill_parent" android:layout_height="1px" android:background="#FF909090" />
C'est la solution que j'ai utilisé mais je l'ai codé dans java pour pouvoir la réutiliser plusieurs fois dans la vue.
En fait, je n'ai pas trouvé comment réutiliser une view XML plusieurs fois sans que cela génère une erreur : dont je l'ai codé.
Si tu sais comment faire ce dernier point, je suis preneur.
Au fait : +1 :mouarf:
A+ ;)
Je te remercie pour ton aide mais je l'ai mis en place sans succès.
Je veux pouvoir reproduire le menu suivant (fichier : menu_contact.xml) :
En fait, c'est le même problème de reproductibilité que la ligne de séparation
... avec le code suivant :Code:
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 <?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="wrap_content" android:layout_marginLeft="2dp" android:background="#ffffff" android:gravity="center" android:orientation="horizontal" android:paddingBottom="4dp" android:paddingTop="4dp" android:id="@+id/menu_contact" android:weightSum="1.00" > <Button android:id="@+id/menu_contact_call" android:layout_width="wrap_content" android:layout_height="wrap_content" android:drawableLeft="@drawable/call_contact" android:gravity="center" android:onClick="selfCall" /> <Button android:id="@+id/menu_contact_send" android:layout_width="wrap_content" android:layout_height="wrap_content" android:drawableLeft="@drawable/send_contact" android:gravity="center" android:onClick="selfSend" /> </LinearLayout>
... sachant que le fichier correspond à l'activité est le suivant (fichier : annonces.xml) :Code:
1
2
3
4
5 LinearLayout ll = (LinearLayout) findViewById(R.id.annonces_root); LayoutInflater mInflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE); View v= mInflater.inflate(R.layout.menu_contact, ll, false); ll.addView(v);
Peux-tu m'aider à comprendre enfin le soucis ?Code:
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 <?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/scroller" android:layout_width="fill_parent" android:layout_height="fill_parent" android:fillViewport="true" > <LinearLayout android:id="@+id/annonces_root" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="#ffffff" android:weightSum="1.0" android:orientation="vertical" > <ImageView android:id="@+id/annonces_banniere" android:layout_width="fill_parent" android:layout_height="wrap_content" android:scaleType="center" android:layout_marginTop="2dp" android:contentDescription="@string/app_name" /> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="#ffffff" android:layout_marginLeft="2dp" android:paddingTop="0dp" android:paddingBottom="10dp" android:weightSum="1.0" android:orientation="horizontal"> <TextView android:id="@+id/annonces_preferences" android:textColor="#35bbed" android:textStyle="bold" android:textSize="11dp" android:layout_width="0dp" android:layout_weight="0.90" android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:text="@string/app_name" android:layout_marginBottom="5dp" android:textAppearance="?android:attr/textAppearanceSmall" /> <Button android:id="@+id/annonces_refresh" android:gravity="center" android:layout_width="0dp" android:layout_weight="0.10" android:layout_height="wrap_content" android:layout_marginTop="20dp" android:layout_marginRight="10dp" android:maxHeight="20dp" android:maxWidth="20dp" /> </LinearLayout> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/annonces_layoutOfDynamicContent"> </LinearLayout> </LinearLayout> </ScrollView>
Merci encore.
A+ ;)
Salut, sans te préoccuper d'une insertion, tu peux augmenter les marges hautes et basses afin de créer graphiquement une ligne de séparation:
android:layout_Margin_top="25dp"
android:layout_Margin_bottom="25dp"
ou encore insert une layout horizontal dont tu modifier le background,
voilou ::http://developer.android.com/referen...outParams.html
En regardant la doc, je tombe là dessus :
http://developer.android.com/referen...ml#getDivider()