gpt4 book ai didi

java - 如何修复错误膨胀类 android.support.design.widget.NavigationView

转载 作者:行者123 更新时间:2023-12-02 09:26:43 26 4
gpt4 key购买 nike

我遇到问题,但找不到解决方案!我在 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

在应用程序中: APP PAGE

最佳答案

在您的 build.gradle 中有一些错误:

  • 支持库 29.0.2 和 29.1.1 不存在
  • 您正在同时使用androidx 和支持库,并且您不能这样做。

然后,由于您使用的是 androidx 组件 <androidx.drawerlayout.widget.DrawerLayout你必须使用

<com.google.android.material.navigation.NavigationView
...>

而不是 android.support.design.widget.NavigationView .

最后检查您的应用程序主题。您必须使用Material Component Theme

关于java - 如何修复错误膨胀类 android.support.design.widget.NavigationView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58292869/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com