如何从片段隐藏底部导航

时间:2019-08-15 23:11:30

标签: android fragment

我有一个活动女巫,其中包含FrameLayoutBottomNavigationView,如下所示:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:layout_height="match_parent"
    android:background="@color/Grizzly"
    tools:context=".MainActivity">

    <FrameLayout
        android:id="@+id/main_frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@id/btn_nav_bar" />

    <android.support.design.widget.BottomNavigationView
        android:id="@+id/btn_nav_bar"
        android:layout_width="match_parent"
        android:layout_height="56dp"
        app:menu="@menu/nav_items" />

</RelativeLayout>

有什么方法可以将BottomNavigationView内的某个片段中的FrameLayout隐藏起来吗?

1 个答案:

答案 0 :(得分:0)

解决方案是如此简单,我犯了一个非常严重的错误,解决方案是:

navigationView.setVisibility(View.GONE);

您必须注意的是,您应该找到这样的视图NavigationView:

navigationView = getActivity().findViewById(R.id.btn_nav_bar);