如何在没有主题中的noActionBar的情况下删除片段中的应用程序栏

我需要删除这个 home_fragment
操作栏,但我无法在 themes.xml
中编写 NoActionBar
因为底部导航无法以这种方式工作。有人有什么解决办法吗?
另外,看一下照片,这将有助于理解问题。 这是底部导航活动 XML
中给出的代码
<?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"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
style="@style/Theme.AppCompat.DayNight.NoActionBar">
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/nav_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="0dp"
android:layout_marginEnd="0dp"
android:background="?android:attr/windowBackground"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="@menu/bottom_nav_menu" />
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/topAppBar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:title="Add player fragment"
app:menu="@menu/top_app_bar"
app:layout_constraintTop_toTopOf="parent"
style="@style/Widget.MaterialComponents.Toolbar.Primary"/>
<fragment
android:id="@+id/nav_host_fragment_activity_bottom_navigation_main"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="0dp"
app:defaultNavHost="true"
app:layout_constraintBottom_toTopOf="@id/nav_view"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/topAppBar"
app:navGraph="@navigation/mobile_navigation"/>
</androidx.constraintlayout.widget.ConstraintLayout>
I need to remove this home_fragment
action bar, but I can't write NoActionBar
in themes.xml
because bottom navigation won't work that way. Anyone has any solution?
Also, take a look at the photo, it will help understand the problem.
This is the code given in bottom navigation activity XML
<?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"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
style="@style/Theme.AppCompat.DayNight.NoActionBar">
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/nav_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="0dp"
android:layout_marginEnd="0dp"
android:background="?android:attr/windowBackground"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="@menu/bottom_nav_menu" />
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/topAppBar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:title="Add player fragment"
app:menu="@menu/top_app_bar"
app:layout_constraintTop_toTopOf="parent"
style="@style/Widget.MaterialComponents.Toolbar.Primary"/>
<fragment
android:id="@+id/nav_host_fragment_activity_bottom_navigation_main"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="0dp"
app:defaultNavHost="true"
app:layout_constraintBottom_toTopOf="@id/nav_view"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/topAppBar"
app:navGraph="@navigation/mobile_navigation"/>
</androidx.constraintlayout.widget.ConstraintLayout>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以尝试将这两行添加到主题中。xml文件
主题。xml文件看起来像这样

You can try adding these two lines to your themes.xml files
Themes.xml file looks like this
