【问题标题】:How to use bottom navigation bar and side navigation bar together, my side navigation button is not showing when i but bottom navigation如何一起使用底部导航栏和侧边导航栏,我的侧边导航按钮不显示,而是底部导航
【发布时间】:2020-01-29 10:54:24
【问题描述】:

我同时使用导航栏和底部导航栏,但我的侧导航抽屉没有显示,我在其中放置 FrameLayout 和底部导航代码。

【问题讨论】:

    标签: java android navigation-drawer android-bottomnavigationview


    【解决方案1】:

    您的 XML 代码必须采用以下格式

    <?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:layout_height="match_parent"
        android:fitsSystemWindows="true"
        android:id="@+id/drawer_layout"
        tools:context=".ui.activity.HomeActivity">
    
        <androidx.coordinatorlayout.widget.CoordinatorLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
    
            <FrameLayout
                android:id="@+id/fragments"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:fitsSystemWindows="true"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintRight_toRightOf="parent"
                app:layout_constraintTop_toTopOf="parent">
    
            </FrameLayout>
    
            <com.google.android.material.bottomnavigation.BottomNavigationView
                android:id="@+id/nav_view"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="bottom"
                android:layout_marginStart="0dp"
                android:layout_marginEnd="0dp"
                android:background="?android:attr/windowBackground"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintLeft_toLeftOf="parent"
                app:menu="@menu/bottom_nav_menu" />
        </androidx.coordinatorlayout.widget.CoordinatorLayout>
    
        <com.google.android.material.navigation.NavigationView
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_gravity="start"
            android:background="#ffffff"
            android:id="@+id/sideNavigationView"
            app:headerLayout="@layout/layout_nav_header"
            app:itemIconTint="#000"
            app:itemTextColor="#000"
            app:menu="@menu/side_nav_menu">
    
        </com.google.android.material.navigation.NavigationView>
    
    </androidx.drawerlayout.widget.DrawerLayout>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多