未处理的异常:Android.Views.InflateException:二进制XML文件行#1:二进制XML文件行#1

时间:2018-04-10 04:09:47

标签: android xamarin xamarin.android

在Xamarin Android中,当我从Activity调用axml文件时,我收到错误,

  

“未处理的例外:

     

Android.Views.InflateException:二进制XML文件行#1:二进制XML   文件行#1:错误膨胀类   android.support.design.widget.BottomNavigationView发生了“

我已经在这里呆了两天而且我没有得到错误的原因。请帮帮我。

我在这一行收到错误,

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>

提前感谢。

2 个答案:

答案 0 :(得分:0)

您可以发布您正在使用的活动的代码吗? 此代码: SetContentView(Resource.Layout.main_page);

您是否在活动中找到了BottomNavigationView的引用 通过写BottomNavigationView bottomView =
 FindViewById(Resource.id.hereYourIdOfBottomNavigationView);

如果您没有找到,请尝试查找然后运行您的代码。

答案 1 :(得分:0)

您的activity应该继承AppCompatActivity 并确保您的Xamarin.Android.Support.DesignXamarin.Android.Support.v7.AppCompat版本相同。

相关问题