为什么我有两个标题?以及如何去除上部标题?



我想创建一个"注册"导航栏,但是RegistrationForm"也是可见的。如何去除?MainActivity.java

   MaterialToolbar toolbar;
    toolbar=findViewById(R.id.topAppBar);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showPopup(toolbar);
        }
    });

}

public void showPopup(View v) {
    PopupMenu popup = new PopupMenu(this, v);
    MenuInflater inflater = popup.getMenuInflater();
    inflater.inflate(R.menu.other, popup.getMenu());
    popup.show();
}

MainActivity.xml

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

Popup.xml

<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
    android:id="@+id/search"
    android:icon="@android:drawable/ic_menu_search"
    android:title="@string/more"/>

在这里输入图像描述我有两个标题(导航栏)一个在另一个下面。但是我不能去掉上页眉(导航栏)。这是原始的页眉。所以我试着找出如何删除上部标题

进入样式文件夹(在res ->价值观——比;样式文件夹),并更改您的材料主题为Theme.MaterialComponents.DayNight.NoActionBar

<
    resources xmlns:tools="http://schemas.android.com/tools">
        <!-- Base application theme. -->
        <style name="Theme.YourApp" parent="Theme.MaterialComponents.DayNight.NoActionBar"> ...

.