在Xamarin Android中,当我从Activity调用axml文件时,我得到的错误是,
"未处理的异常:
Android.Views.InflateException: Binary XML file 行 #1: Binary XML 文件行 #1:膨胀类时出错 android.support.design.widget.BottomNavigationView 發生了">
我已经在这里呆了 2 天,我没有找到错误的原因。请帮助我。
我在这一行中遇到错误,
SetContentView(Resource.Layout.main_page);
我的 axml 文件是,
<?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"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/bottom_navigation" />
<android.support.design.widget.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="56dp"
android:layout_alignParentBottom="true"
android:background="@android:color/white"
app:elevation="16dp"
app:menu="@menu/bottom_navigation_main"/>
</RelativeLayout>
提前谢谢。
你能发布你正在使用的活动的代码吗此代码: SetContentView(Resource.Layout.main_page(;
您是否在活动中找到了底部导航视图的参考通过编写底部导航视图底部视图=
FindViewById (Resource.id.hereYourIdOfBottomNavigationView(;
如果找不到,请尝试查找,然后运行代码。
你的activity
应该继承自 AppCompatActivity
.
并确保您的Xamarin.Android.Support.Design
和Xamarin.Android.Support.v7.AppCompat
版本相同。