我有一个片段在 MainActivity 上没有正确显示,顶部的汉堡菜单根本没有显示,片段的底部被剪切并且看不到。
activity_main.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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<ScrollView
android:id="@+id/svFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="@id/bnvNavigation" >
<FrameLayout
android:id="@+id/flScreen"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</ScrollView>
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bnvNavigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/brightNeutral"
app:itemActiveIndicatorStyle="@color/main_activity_bottom_navigation_menu_colors"
app:itemIconTint="@color/main_activity_bottom_navigation_menu_colors"
app:itemTextColor="@color/main_activity_bottom_navigation_menu_colors"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:menu="@menu/main_activity_bottom_navigation_menu" />
</androidx.constraintlayout.widget.ConstraintLayout>
请注意,我无法向上滚动查看汉堡菜单。如果我尝试向下滚动,我会看到“毕达哥拉斯定理”被切在中间。
我尝试更改布局但没有成功。
您可能只是将
com.google.android.material.navigation.NavigationView
与 com.google.android.material.bottomnavigation.BottomNavigationView
混淆了。汉堡包图标是导航视图的一部分,用于在屏幕左侧打开抽屉布局,底部导航视图是底部的菜单。这是官方文档如何实现NavigationView!