Bonjour,

Je débute dans la programmation et j'essaie de coder une application android dans Android Studio.
Pour cela, je souhaite rajouter une app bars en haut de mon activity_main, j'ai donc suivi les consignes de cette page : https://material.io/components/app-b...g-top-app-bars. J'ai donc mis ce code dans mon activity_main :

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
<androidx.coordinatorlayout.widget.CoordinatorLayout
    ...
    android:layout_width="match_parent"
    android:layout_height="match_parent">
 
    <com.google.android.material.appbar.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
 
        <com.google.android.material.appbar.MaterialToolbar
            android:id="@+id/topAppBar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:title="@string/page_title"
            app:menu="@menu/top_app_bar"
            app:navigationIcon="@drawable/ic_menu_24dp"
            style="@style/Widget.MaterialComponents.Toolbar.Primary"
            />
 
    </com.google.android.material.appbar.AppBarLayout>
 
    <!-- Note: A RecyclerView can also be used -->
    <androidx.core.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">
 
        <!-- Scrollable content -->
 
    </androidx.core.widget.NestedScrollView>
 
</androidx.coordinatorlayout.widget.CoordinatorLayout>

Je rencontre alors deux problèmes :

1. Les 'android :' sont signalés comme des erreurs

J'obtiens donc ce code en les supprimant :
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
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
    layout_width="match_parent"
    layout_height="match_parent">

    <com.google.android.material.appbar.AppBarLayout
        layout_width="match_parent"
        layout_height="wrap_content">

    <com.google.android.material.appbar.MaterialToolbar
        id="@+id/topAppBar"
        layout_width="match_parent"
        layout_height="?attr/actionBarSize"
        title="@string/page_title"
        menu="@menu/top_app_bar"
        navigationIcon="@drawable/ic_menu_24dp"
        style="@style/Widget.MaterialComponents.Toolbar.Primary"
        />

    </com.google.android.material.appbar.AppBarLayout>

        <!-- Note: A RecyclerView can also be used -->
    <androidx.core.widget.NestedScrollView
    layout_width="match_parent"
    layout_height="match_parent"
    layout_behavior="@string/appbar_scrolling_view_behavior">

    <!-- Scrollable content -->

    </androidx.core.widget.NestedScrollView>

</androidx.coordinatorlayout.widget.CoordinatorLayout>

2. Sur les 3 lignes, en violet, j'ai les deux erreurs:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
Define layout_widht attribute
et
Code : Sélectionner tout - Visualiser dans une fenêtre à part
Define layout_widht attribute

Je n'arrive pas à comprendre ce problème,
Avez-vous une idée pour le résoudre ?
Merci d'avance,
Alphae