Bonjour, je suis débutant dans le langage Java, j'ai cependant des connaissances dans le langage web tel que PHP, HTML, XML, CSS et JavaScript.
Je viens d'installer Android Studio, je suis actuellement un tuto pour faire une simple appli, rien de bien compliqué mais le souci c'est l'IDE qui lorsque je souhaite faire référence à un style créé dans mon themes.xml, il me trouve pas le style en question.
Mon @style/DefaultTextStyle et @style/TitleTextStyle sont en erreur :
Cannot resolve symbol '@style/[le style demandé]'
Dans mon themes.xml, j'ai :
Et dans mon activity_main.xml, j'ai :
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 <resources xmlns:tools="http://schemas.android.com/tools"> <!-- Base application theme. --> <style name="Theme.NatureCollection" parent="Theme.AppCompat.Light.NoActionBar"> <!-- Primary brand color. --> <item name="colorPrimary">@color/purple_500</item> <item name="colorPrimaryVariant">@color/purple_700</item> <item name="colorOnPrimary">@color/white</item> <!-- Secondary brand color. --> <item name="colorSecondary">@color/teal_200</item> <item name="colorSecondaryVariant">@color/teal_700</item> <item name="colorOnSecondary">@color/black</item> <!-- Status bar color. --> <item name="android:statusBarColor">?attr/colorPrimaryVariant</item> <!-- Customize your theme here. --> <style name="DefaultTextStyle"> <item name="android:textColor">@color/lightGray</item> <item name="android:textSize">18sp</item> <item name="android:fontFamily">@font/kani</item> </style> <style name="SubtitleTextStyle" parent="DefaultTextStyle"> <item name="android:textColor">@color/darkGray</item> </style> <style name="TitleTextStyle" parent="SubtitleTextStyle"> <item name="android:textSize">24sp</item> </style> </style> </resources>
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 <?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> <TextView android:id="@+id/app_title" style="@style/DefaultTextStyle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="@dimen/default_margin" android:layout_marginTop="@dimen/default_margin" android:text="@string/app_name" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> <TextView android:id="@+id/page_title" style="@style/TitleTextStyle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/home_page_title" app:layout_constraintStart_toStartOf="@+id/app_title" app:layout_constraintTop_toBottomOf="@+id/app_title" /> </androidx.constraintlayout.widget.ConstraintLayout>
Partager