【问题标题】:Why I have two headers? And how to remove upper header?为什么我有两个标题?以及如何删除上标题?
【发布时间】:2021-07-23 12:12:11
【问题描述】:

我想创建一个“注册”导航栏,但“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"/>

enter image description here 我有两个标题(导航栏),一个在另一个下方。但我无法摆脱上部标题(导航栏)。这是原始标题。所以我试图弄清楚如何删除上标题

【问题讨论】:

    标签: java android xml uinavigationbar


    【解决方案1】:

    转到您的样式文件夹(在 res --> values ---> 样式文件夹下)并将您的 Material Theme 更改为 Theme.MaterialComponents.DayNight.NoActionBar

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

    .

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-01-15
      • 2015-04-28
      • 1970-01-01
      • 1970-01-01
      • 2014-10-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多