Bonjour,
Je suis en train de développer une petite application comme l'image le montre. Le soucis, c'est que je l'ai faite pour un S3 mini. Comment la rendre polyvalente pour tous les smartphones ?
Merci de votre aide
Jennifer
Pièce jointe 156214
Version imprimable
Bonjour,
Je suis en train de développer une petite application comme l'image le montre. Le soucis, c'est que je l'ai faite pour un S3 mini. Comment la rendre polyvalente pour tous les smartphones ?
Merci de votre aide
Jennifer
Pièce jointe 156214
Sans code, ça va être très dur de t'aider.
Normalement, si tu as bien fait, ton interface devrait avoir le même look sous tout les terminaux (donc utilisation de dp, de 9patch, de relativité de remplissage...).
Tu as testé sous un autre terminal et ça a totalement déconné ?
Merci de ta réponse. Je vais mettre le code de mon fichier activity_my.xml
Quand c'est noté "+id/textView", c'est pour faire un espace entre deux textes !!
Merci de votre aide
Jennifer
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
73
74
75
76
77
78
79
80
81
82
83
84
85<!-- Version --> <TextView android:layout_width="355dp" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:text="" android:id="@+id/textView" android:layout_gravity="center_horizontal" android:layout_weight="0.06" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:text="@string/valueInitTemperature" android:id="@+id/labTemperature" android:gravity="center" android:textSize="70sp" android:textAlignment="center" android:textStyle="bold" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:text="@string/valueInitStatus" android:id="@+id/labStatus" android:gravity="center" android:layout_weight="0.06" android:textStyle="bold" /> <TextView android:layout_width="355dp" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:text="" android:id="@+id/textView2" android:layout_gravity="center_horizontal" android:layout_weight="0.06" /> <ImageButton android:layout_width="100dp" android:layout_height="100dp" android:id="@+id/imageButton" android:layout_gravity="center_horizontal" android:contentDescription="@string/valueInitZero" android:focusable="false" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceMedium" android:text="" android:id="@+id/textView3" android:layout_gravity="center_horizontal" android:layout_weight="0.06" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceMedium" android:text="" android:id="@+id/textView4" android:layout_gravity="center_horizontal" android:layout_weight="0.06" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceMedium" android:text="@string/valueInitZero" android:id="@+id/labCopyright" android:layout_gravity="center_horizontal" android:layout_weight="0.06" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceMedium" android:text="@string/valueInitZero" android:id="@+id/labCellVolt" android:layout_gravity="center_horizontal" android:layout_weight="0.06" /> </LinearLayout>
Pas très élégant, mais on dirait que ça fonctionne en mode portrait sur d'autres terminaux.
Je te suggère d'utiliser la pré-visualisation d'Android Studio et d'Eclipse lorsque tu crée tes interfaces, avec un échantillon représentatif pour être sûre.
Je te déconseille aussi les valeurs absolues comme tu le fais. Ca marche pour une seule orientation, mais ça te posera de jolies problèmes en mode paysage. Je te suggère de plutôt passer par des poids généraux et des Layout pour organiser tes widgets.
De mon côté, le XML qui fait la même chose que toi, à un détail près à priori :
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 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:layout_weight="1" android:gravity="center" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="60dp" tools:text="24.6°C" android:text="@string/valueInitTemperature" android:id="@+id/labTemperature" android:textSize="70sp" android:textStyle="bold" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" tools:text="Connected" android:text="@string/valueInitStatus" android:id="@+id/labStatus" android:textStyle="bold" /> </LinearLayout> <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/imageButton" android:contentDescription="@string/valueInitZero" android:layout_gravity="center_horizontal" android:focusable="false" android:layout_weight="1"/> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:layout_weight="1" android:gravity="center"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/valueInitZero" tools:text="(c) Jennifer ALBINAIS v3.0" android:id="@+id/labCopyright"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/valueInitZero" tools:text="2977mV" android:id="@+id/labCellVolt" /> </LinearLayout> </LinearLayout>
Cette version fonctionne en mode paysage aussi, mais te demandera sans doute un peu plus de boulot au niveau de l'ImageButton pour que la taille soit bien adaptée.
Je te suggère aussi de bien utiliser les android:text pour mettre ton texte. Ca t'évitera de passer par le code pour le faire. De même pour les images (android:src).
HS : le tools:... correspond à une aide au design pour la prévisualisation et n'intervient en aucun cas au runtime. Cela permet simplement du remplissage avec valeur de test pour aider lors de la construction.
Ps : oui, j'avais envie de faire une interface :D
Ps ² : je suis moi aussi ouvert aux critiques :)
GRAND MERCI
le plus :
- cela fonctionne
les moins :
- il y a encore du travaille mais si je voulais un thermomètre tout fait, j'avais qu'à aller à Carrefour :lol:
- les simulateurs sont très lents :( même avec un ordinateur puissant
- le logo (l'image) ne va pas être facile selon l'écran
MAIS GRAND MERCI
Jennifer
Je te conseille vraiment d'utiliser genymotion en lieu et place du simulateur officiel, la différence est flagrante.
encore MERCI
Genymotion fonctionne très bien sur MAC et surtout est 100 fois plus rapide
Merci
Jennifer