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
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
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é ?
C'est Android, PAS Androïd, ou Androïde didiou !
Le premier est un OS, le second est la mauvaise orthographe du troisième, un mot français désignant un robot à forme humaine.
Membre du comité contre la phrase "ça marche PAS" en titre et/ou explication de problème.
N'oubliez pas de consulter les FAQ Android et les cours et tutoriels Android
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 : 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 <!-- 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 XML : 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 <?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
Ps ² : je suis moi aussi ouvert aux critiques
C'est Android, PAS Androïd, ou Androïde didiou !
Le premier est un OS, le second est la mauvaise orthographe du troisième, un mot français désignant un robot à forme humaine.
Membre du comité contre la phrase "ça marche PAS" en titre et/ou explication de problème.
N'oubliez pas de consulter les FAQ Android et les cours et tutoriels Android
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
- 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.
Hey, this is mine. That's mine. All this is mine. I'm claiming all this as mine. Except that bit. I don't want that bit. But all the rest of this is mine. Hey, this has been a really good day. I've eaten five times, I've slept six times, and I've made a lot of things mine. Tomorrow, I'm gonna see if I can't have sex with something.
encore MERCI
Genymotion fonctionne très bien sur MAC et surtout est 100 fois plus rapide
Merci
Jennifer
Vous avez un bloqueur de publicités installé.
Le Club Developpez.com n'affiche que des publicités IT, discrètes et non intrusives.
Afin que nous puissions continuer à vous fournir gratuitement du contenu de qualité, merci de nous soutenir en désactivant votre bloqueur de publicités sur Developpez.com.
Partager