我在Xamarin.Android项目中使用Layout启动Activity时遇到此错误。如何解决这个问题?所有android nuget软件包v。28.0.0.3
Android.Views.InflateException:'二进制XML文件第1行:二进制XML文件第1行:膨胀类android.suppot.design.widget.NavigationView时出错”
XAML
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:id="@+id/drawerLayout"
android:fitsSystemWindows="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<include
layout="@layout/include_main"
/>
</LinearLayout>
<android.suppot.design.widget.NavigationView
android:id="@+id/navView"
android:layout_height="match_parent"
android:layout_width="300dp"
android:background="@android:color/white"
android:layout_gravity="start"
app:headerLayout="@layout/headerlayout"
app:menu="@menu/navmenu"
/>
</android.support.v4.widget.DrawerLayout>
NavMenu
<?xml version="1.0" encoding="utf-8" ?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group>
<item
android:id="@+id/navProfile"
android:title="Профиль"
android:icon="@mipmap/ic_person"/>
<item android:id="@+id/navPayments"
android:icon="@mipmap/ic_wallet"
android:title="Транзакции"/>
<item android:id="@+id/navHistory"
android:title="История"
android:icon="@mipmap/ic_history"
/>
<item
android:id="@+id/navPromo"
android:title="Промо"
android:icon="@mipmap/ic_discount"
/>
<item
android:id="@+id/navSupport"
android:title="Поддержка"
android:icon="@mipmap/ic_support"
/>
<item
android:id="@+id/navAbout"
android:title="О нас"
android:icon="@mipmap/ic_about"
/>
</group>
</menu>
Include_main
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rootView"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Main Layout"
android:textSize="20sp"
android:gravity="center"
android:layout_gravity="center"
/>
</FrameLayout>
</android.support.design.widget.CoordinatorLayout>
header_layout
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="200dp"
android:background="@android:color/white"
android:theme="@style/ThemeOverlay.AppCompat.Dark">
<Refractored.Controls.CircleImageView
android:id="@+id/accoutImage"
android:layout_height="100dp"
android:layout_width="100dp"
android:layout_gravity="center"
android:src="@drawable/account"
android:scaleType="centerCrop"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/accountTitle"
android:layout_gravity="bottom"
android:gravity="center"
android:text="UserName"
android:layout_marginBottom="12dp"
/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_gravity="bottom"
android:background="@android:color/holo_blue_dark"/>
</FrameLayout>
styles.xml
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<style name="Theme.Splash"
parent="Theme.AppCompat.NoActionBar">
<item name="windowNoTitle">true</item>
<item name="android:windowBackground">@drawable/splash</item>
</style>
<style name="Theme.Register" parent="Theme.AppCompat.NoActionBar">
<item name="windowNoTitle">true</item>
</style>
<style name="MainTheme" parent="MainTheme.Base">
</style>
<!-- Base theme applied no matter what API -->
<style name="MainTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<!--If you are using revision 22.1 please use just windowNoTitle. Without android:-->
<item name="windowNoTitle">true</item>
<!--We will be using the toolbar so no need to show ActionBar-->
<item name="windowActionBar">false</item>
<!-- Set theme colors from http://www.google.com/design/spec/style/color.html#color-color-palette ->
<!-- colorPrimary is used for the default action bar background -->
<item name="colorPrimary">@color/colorPrimary</item>
<!-- colorPrimaryDark is used for the status bar -->
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<!-- colorAccent is used as the default value for colorControlActivated
which is used to tint widgets -->
<item name="colorAccent">@color/colorAccent</item>
<!-- You can also set colorControlNormal, colorControlActivated
colorControlHighlight and colorSwitchThumbNormal. -->
<item name="windowActionModeOverlay">true</item>
<item name="android:datePickerDialogTheme">@style/AppCompatDialogStyle</item>
</style>
<style name="AppCompatDialogStyle" parent="Theme.AppCompat.Light.Dialog">
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
尝试更改refractored.controls.CircleImageView
中的Refractored.Controls.CircleImageView
而不是header_layout
:
<refractored.controls.CircleImageView
android:id="@+id/accoutImage"
android:layout_height="100dp"
android:layout_width="100dp"
android:layout_gravity="center"
android:src="@drawable/account"
android:scaleType="centerCrop"
/>
您拼写了support
一词。只需尝试替换
<android.suppot.design.widget.NavigationView>
与
<android.support.design.widget.NavigationView>