隐藏底部导航栏在打开侧滑菜单时。

huangapple go评论74阅读模式
英文:

hiding bottom navigation view when open slide menu

问题

我在项目中有一个带有2个“底部导航视图”的布局,并且每个片段都有一个“侧滑菜单”(导航视图),我希望在任何一个菜单显示时隐藏“底部导航视图”,有人可以给我一个示例该如何做吗?如果有类似的问题,如果您能展示给我,我会很高兴,因为我没有找到类似的内容。

英文:

I have a bottom navigation view in my project with 2 fragments and every fragment has a slide menu (navigation view) and I want to hide the bottom navigation view when any of my menus is showing,can someone give me an example how to do that?and if there is a similar question, I would be glad if you would show me it, because I have not found anything similar

答案1

得分: 0

以下是翻译好的内容:

如果您的布局像这样:

<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout
    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:id="@+id/drawer_layout"
    tools:openDrawer="start"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_alignParentBottom="true"
        android:layout_height="?attr/actionBarSize">
        <com.google.android.material.bottomnavigation.BottomNavigationView
            android:layout_alignParentBottom="true"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:menu="@menu/buttom_nav_menu"/>
    </RelativeLayout>

    <com.google.android.material.navigation.NavigationView
        android:layout_gravity="start"
        app:menu="@menu/menu"
        android:layout_width="330dp"
        android:layout_height="match_parent"/>
</androidx.drawerlayout.widget.DrawerLayout>

您将不需要隐藏 bottom navigation view,因为滑动菜单位于其前方。

英文:

if your layout like this :

&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;androidx.drawerlayout.widget.DrawerLayout
xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
xmlns:tools=&quot;http://schemas.android.com/tools&quot;
android:layout_width=&quot;match_parent&quot;
android:id=&quot;@+id/drawer_layout&quot;
tools:openDrawer=&quot;start&quot;
android:layout_height=&quot;match_parent&quot;
tools:context=&quot;.MainActivity&quot;&gt;

&lt;RelativeLayout
    android:layout_width=&quot;match_parent&quot;
    android:layout_alignParentBottom=&quot;true&quot;
    android:layout_height=&quot;?attr/actionBarSize&quot;&gt;
&lt;com.google.android.material.bottomnavigation.BottomNavigationView
    android:layout_alignParentBottom=&quot;true&quot;
    android:layout_width=&quot;match_parent&quot;
    android:layout_height=&quot;?attr/actionBarSize&quot;
    app:menu=&quot;@menu/buttom_nav_menu&quot;/&gt;
&lt;/RelativeLayout&gt;

&lt;com.google.android.material.navigation.NavigationView
    android:layout_gravity=&quot;start&quot;
    app:menu=&quot;@menu/menu&quot;
    android:layout_width=&quot;330dp&quot;
    android:layout_height=&quot;match_parent&quot;/&gt;

&lt;/androidx.drawerlayout.widget.DrawerLayout&gt;

you will not need to hide the bottom navigation view because the slide menu is in front of it

huangapple
  • 本文由 发表于 2020年9月14日 00:20:42
  • 转载请务必保留本文链接:https://go.coder-hub.com/63872948.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定