Android (Xamarin):底部导航视图没有出现在正确的地方



我正试图实现一个底部导航栏为我的Android应用程序(API 30),使用BottomNavigationView类从Android.Support.Design.Widget命名空间(Xamarin.Android.Support.)。设计库,28.0.0.3版本)。我遵循这里的解释:https://devblogs.microsoft.com/xamarin/exploring-androids-bottom-navigation-view/

布局文件是这样的:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schema.android.com/apk/res/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/navigator"/>
<android.support.design.widget.BottomNavigationView android:id="@+id/navigator"
android:layout_width="match_parent"
android:layout_height="64dp"
android:layout_gravity="bottom"
android:background="@android:color/white"
app:elevation="16dp"
app:menu="@menu/navigator"/>
</RelativeLayout>

下面是菜单文件:

<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:id="@+id/home"
android:icon="@drawable/home"
android:title="Home"
android:enabled="true"
app:showAsAction="ifRoom"/>
<item android:id="@+id/library"
android:icon="@drawable/library"
android:title="Library"
android:enabled="true"
app:showAsAction="ifRoom"/>
<item android:id="@+id/search"
android:icon="@drawable/search"
android:title="Search"
android:enabled="true"
app:showAsAction="ifRoom"/>
</menu>

问题是,虽然它是可见的,但它出现在屏幕的顶部而不是底部,这与底部导航条应该做的完全相反。此外,它不显示图标。它只是在页面顶部显示一个空白的白色条。

我做错了什么,我如何解决它?

<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="0dp"
android:layout_marginStart="0dp"
android:background="?android:attr/windowBackground"
app:menu="@menu/navigation"
android:layout_gravity="bottom"
android:visibility="visible" />

最新更新