二进制 XML 文件错误膨胀 RecyclerView

Binary XML File Error Inflating RecyclerView

我不断收到此错误:

Binary XML file line #11: Error inflating class androidx.recyclerview.widget.RecyclerView

我在这个网站上看了很多回复,但我还没有纠正这个问题。除其他外,我还添加了新的实现。收到任何帮助将不胜感激。

谢谢

错误代码

java.lang.RuntimeException: Unable to start activity ComponentInfo{rslpf.pa.myapplication/rslpf.pa.myapplication.MainActivity}: android.view.InflateException: Binary XML file line #11: Error inflating class androidx.recyclerview.widget.RecyclerView
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
    at android.app.ActivityThread.access0(ActivityThread.java:151)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:135)
    at android.app.ActivityThread.main(ActivityThread.java:5254)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
 Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class androidx.recyclerview.widget.RecyclerView
    at android.view.LayoutInflater.createView(LayoutInflater.java:633)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
    at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555)
    at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
    at rslpf.pa.myapplication.MainActivity.onCreate(MainActivity.java:32)

请在下面找到我的 XML 文件部分:

<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">



<androidx.recyclerview.widget.RecyclerView

    android:id="@+id/recycler_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#FFFFFF"/>

</RelativeLayout>

Gradle 依赖关系:

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'

//implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.android.volley:volley:1.1.0'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'androidx.recyclerview:recyclerview:1.1.0';

}

@android:color/primary_text_dark是颜色选择器,你应该替换成你的颜色,不要使用颜色选择器,同

<?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"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">
    <androidx.recyclerview.widget.RecyclerView

        android:id="@+id/recycler_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#FFFFFF"/>
</RelativeLayout>