如何解决膨胀类android.support.design.widget.NavigationView的错误

问题描述 投票:0回答:2

我有问题,我找不到解决方案!我在XML中使用:

<?xml version="1.0" encoding="utf-8"?>

    <androidx.drawerlayout.widget.DrawerLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      android:id="@+id/activity_main"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context="com.example.libraryproject.MainActivity"
      android:background="@android:color/holo_green_dark">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">


        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Main"
            android:textSize="50dp"
            android:id="@+id/textView"
            android:layout_marginTop="200dp"
            android:layout_marginLeft="130dp"/>


    </RelativeLayout>

    <android.support.design.widget.NavigationView ------! #32
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        app:menu="@menu/navigation_menu"
        android:layout_gravity="start"
        app:headerLayout="@layout/navigation_header"
        android:id="@+id/nv">
    </android.support.design.widget.NavigationView>

</androidx.drawerlayout.widget.DrawerLayout>

错误显示为:android.view.InflateException:二进制XML文件第32行:二进制XML文件第32行:错误膨胀了类android.support.design.widget.NavigationView

在应用中:“

java android androidx android-navigationview material-components-android
2个回答
0
投票

您的build.gradle中有一些错误


0
投票

因为使用的是AndroidX,所以将android.support.design.widget.NavigationView替换为com.google.android.material.navigation.NavigationView。>

© www.soinside.com 2019 - 2024. All rights reserved.